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

How to hide particular rows?

1 Answer 16 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brew Hutch
Top achievements
Rank 1
Brew Hutch asked on 16 Aug 2010, 09:14 PM
I have the data as the following

ID ProductName Active
1      "One"              1
2      "Two"              1
3      "Three"        0
4      "Four"             1

I want to hide row id=3 because active is 0 when a grid is bound.
How to accomplish this?

Thanks
Brew

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 17 Aug 2010, 04:50 AM
Hi Brew,


You can access the cell value and set the item visibility based on the value, to achieve this.

Code behind:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        if (item["Active"].Text == "0") // Active is ColumnUniqueName
        {
            item.Display = false// Hide the row
        }
    }       
}

Accessing cells and rows


-Shinu.
Tags
Grid
Asked by
Brew Hutch
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or