Datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,

I have a datagrid with custom columns (autogeneratecolumn=false).

Based on some logic I want to hid a column, or make a column visible.

How can I do that?

Forexample, if I have a <ASP:ButtonColumn> which is visible by default. If
based on certain value , I want to hide it. How can I do that?

Thnx
 
It depends on what conditions would hide the column or show it. If the
condition is in the data then you can use the Visible attribute and databind
it to a value or a function that relies on the underlying data, e.g.

Visible='<%# DataBinder.Eval(Container.DataItem, "DisplayCondition")%>'
or Visible = '<%#
AFunctionThatReturnsBoolean(DataBinder.Eval(Container.DataItem,
"PersonName"))%>'

If you will turn the column hidden in response to a user selection on the
web then use the DataGrid.Columns collection, e.g.
DataGrid1.Columns[0].Visible = false;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top