I had a problem in crafting hyperlinks within a DevExpress ASPxGridView like this in that when I had a JavaScript effect which had to happen upon a mouseover like so:
hyperLink.Attributes.Add("onmouseover", String.Format("ShowToolTips('{0}','{1}',',')", hyperLink.ClientID, _errors));
...there was a problem! One had to click in the page before the mouseover effect would work! At my wireup like this...
Foo.HtmlDataCellPrepared += Foo_HtmlDataCellPrepared;
...which used a method such as this...
private void Foo_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)
{
...I ended up giving up on an expectation of hyperlink management. I instead added a new wireup like this...
Foo.HtmlRowPrepared += Foo_HtmlRowPrepared;
...which used a method such as this...
private void Foo_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e)
{
...which could affect a column like this...
<dx:GridViewDataTextColumn Caption="Validation" Width="80px">
<DataItemTemplate>
<asp:HyperLink ID="ValidationLinkButton" runat="server" CausesValidation="false"
CssClass="FooErrorLink">
</asp:HyperLink>
</DataItemTemplate>
</dx:GridViewDataTextColumn>
...like so:
private void Foo_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e)
{
var grid = sender as ASPxGridView;
if (grid == null) return;
var hyperLink = grid.FindRowCellTemplateControl(e.VisibleIndex, null,
"ValidationLinkButton") as HyperLink;
if (e.RowType == GridViewRowType.Data && hyperLink != null)
{
var foo = grid.GetRow(e.VisibleIndex) as Foo;
if (!string.IsNullOrEmpty(foo.FlattenedErrorList))
{
hyperLink.Text = "Error";
hyperLink.Enabled = false;
hyperLink.Attributes.Add("onmouseover", String.Format("ShowToolTips('{0}','{1}',',')",
hyperLink.ClientID, _errors));
} else {
hyperLink.Visible = false;
}
}
}
Hmmm... as I type this I'm not sure this had to be done. I also changed a CSS class at the links and that helped big. :P
No comments:
Post a Comment