How do I find the index of a DG column with a specific name?

A

Aaron

I have a column called "notes" which may change position in the datagrid.
How do I find the index of this column based on its name?
 
A

Aaron

Thank you very much. This is extremely helpful.


Eliyahu Goldin said:
static public int IndexByName (System.Web.UI.WebControls.DataGrid
grid, string name)
{
for (int col = 0; col < grid.Columns.Count; col++)
if (grid.Columns[col].HeaderText == name)
return col;
return -1;
}

Eliyahu

Aaron said:
Could you give me a code example?

Thanks,
Aaron
 
E

Eliyahu Goldin

static public int IndexByName (System.Web.UI.WebControls.DataGrid
grid, string name)
{
for (int col = 0; col < grid.Columns.Count; col++)
if (grid.Columns[col].HeaderText == name)
return col;
return -1;
}

Eliyahu
 

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

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top