C# – How to hide any row in gridview based on any value

asp.netc

How can I hide a row based on a certain value in GridView?

For example I have a gridview of five column and when the value of column 3 is blank i don't want to display that row, that row should be hidden. So in gridview only those rows should be visible for which column 3 have any value.
I think that this can be done in GridView's RowDataBound -event, but how can I actually hide it ?

Best Answer

try this :

private void GridView_RowDataBound(Object sender, GridViewRowEventArgs e)
 {
    if (e.Row.Cells[2].Text == "") 
        e.Row.Visible = false;
 }