Click here to Skip to main content
14,736,835 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:

How can we hide the datarow/ cells of datarow in specific DataRow in datatable.
Updated 19-Nov-12 18:50pm
Savalia Manoj M 19-Nov-12 23:18pm
please specify your question.
What you want to? You want to remove row from datatable or hide row from grid?


you can set the row hidden in the grid view control in its databound event as follows:

protected void gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
      if (e.Row.RowType == DataControlRowType.DataRow)
         if(conditionToHideRow== true)
           e.Row.Style.Add("visibility", "hidden");
           e.Row.Style.Add("display", "none");
The Gridview has an event named “RowDataBound”. You can add following code in that event

It will remove the row from your datatable dt
Srinubabu Ravilla 19-Nov-12 23:48pm
We can remove the rows in data table by using datatable.remove() method but my requirement is to hide the row of datatable.
NAPorwal(8015059) 20-Nov-12 0:44am
in so far as I understand u dont want to delete the data but want to hide it.
The final task of datatable is ,data to be populated in some data control if u dont want some of data rows to populate then u can use filter that will automatically return the filtered data ,means no need to delete neither to hide any row and the datatable will contain all actual value.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900