Hiding rows server side in ItemDataBound event

2 posts, 0 answers
  1. Somnath
    Somnath avatar
    43 posts
    Member since:
    Jun 2012

    Posted 09 Apr 2012 Link to this post

    Hi ,

    I want hide the rows server side depending on some conditions 
    for that I am using following code 

     protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
      if (e.Item is GridDataItem)  {
     if (//Condition)
                            e.Item.Attributes["style"] = "display:none";  

    However it works perfectly,but I dont want to this, because it renders the row.
    I tried 
    but it wont work, can you please provide me alternate solution.

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 09 Apr 2012 Link to this post

    Hello Ankit,

    Try setting Display property to hide rows.
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
       if (e.Item is GridDataItem)
        GridDataItem item = (GridDataItem)e.Item;
         if (item["EmployeeID"].Text == "1")
             e.Item.Display = false;

Back to Top