This is a migrated thread and some comments may be shown as answers.

Hiding rows server side in ItemDataBound event

1 Answer 371 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Somnath
Top achievements
Rank 1
Somnath asked on 09 Apr 2012, 09:49 AM
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 
e.Item.Visible=false; 
but it wont work, can you please provide me alternate solution.

Thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Apr 2012, 10:06 AM
Hello Ankit,

Try setting Display property to hide rows.
C#:
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;
     }
   }
}

Thanks,
Princy.
Tags
General Discussions
Asked by
Somnath
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or