How to name BoundColumn to set Visible flag in Code Behind?

R

Randall Parker

One can set individual controls in Code Behind by giving the controls ID names and
then declaring corresponding objects for them in Code Behind and then setting Visible
= false or true for each such named control. So far so good.

But with asp:DataGrid and asp:BoundColumn one can not assign an ID to each column
since each column's data row gets reproduced N times for N table rows.

So how to "name" a bound column in order to be able to set the column's visibility in
Code Behind?

I want something like:

ColumnName.Visible = true;

and

ColumnName.Visible = false;

I want to decide at page load time whether particular columns will be visible.

Suggestions?
 
G

Guest

I'm not sure you want to refer Column or Cell. If it's column, you can use

DataGridColumn colName = datagrid.Columns[col_index];

But if it's Cell, it's another story.
 
R

Randall Parker

Elton said:
I'm not sure you want to refer Column or Cell. If it's column, you can use

DataGridColumn colName = datagrid.Columns[col_index];

But if it's Cell, it's another story.

Elton,

I do want to refer to columns. But isn't there some way to refer to columns with
logical names rather than indexes?
 

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

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,112
Latest member
VinayKumar Nevatia
Top