Wednesday, May 14, 2014

add a DevExpress ASPxHyperLink conditionally to some cells of a DevExpress ASPxGridView

private void Foo_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)
{
   if (e.DataColumn.FieldName == "FlattenedErrorList")
   {
      var errors = (string)e.CellValue;
      if (errors.Length > 0)
      {
         ASPxHyperLink hyperLink = new ASPxHyperLink();
         hyperLink.Text = "Error";
         hyperLink.EnableClientSideAPI = true;
         hyperLink.CssClass = "Whatever";
         e.Cell.Text = "";
         e.Cell.Controls.Add(hyperLink);
         e.Cell.HorizontalAlign = HorizontalAlign.Left;
         hyperLink.Attributes.Add("onmouseover", "DoSomething()");
      }
   }
}

No comments:

Post a Comment