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

Hide/Unhide GridBoundColumn run time

3 Answers 207 Views
Grid
This is a migrated thread and some comments may be shown as answers.
hitonline
Top achievements
Rank 1
hitonline asked on 18 Jun 2012, 08:11 PM
I have a requirement of hiding GridBoundColumn  if it does not have any value for any row.
Does RadGrid have any property to know that specific column has any value or not?

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Jun 2012, 03:12 AM
Hi,

Try the following code snippet to hide a GridBoundColumn if it doesn't have a value in any row.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
  {
      GridDataItem ditem = (GridDataItem)e.Item;
      if (ditem["UniqueName"].Text == " ")  
      {
          ditem["UniqueName"].Visible=false; // setting visibility of the GridBoundColumn
      }
  }
}

Thanks,
Shinu.
0
hitonline
Top achievements
Rank 1
answered on 19 Jun 2012, 01:11 PM
Thank you Shinu..
For now I have setup like that only but what I would like to know if Does RadGrid has a property to know Column empty or not?, rather than in Item bound.

And I have to hide column Run time as I have specified and based on some logic.
If Column has at least a single value exist then we would show the column otherwise hide it.
0
Chad
Top achievements
Rank 1
answered on 01 Apr 2014, 06:25 PM
Thank you this helped me!
Tags
Grid
Asked by
hitonline
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
hitonline
Top achievements
Rank 1
Chad
Top achievements
Rank 1
Share this question
or