Link to home
Start Free TrialLog in
Avatar of Kiran_M
Kiran_M

asked on

How do i check if a particular column exists in the datagrid?

The method i am working with takes the following param
myMethod (object sender, DataGridItemEventArgs e)
{
}

The controls on this grid gets dynamically added.
How do i check if a particular column exists on the grid in this method.
ASKER CERTIFIED SOLUTION
Avatar of Anurag Thakur
Anurag Thakur
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dmitry G
Not sure about web controls but try the following:

DataGridItemEventArgs e : e has a property Item. The Item property returns DataGridItem class instance. This instance has a property Parent. Try to cast it to a DataGrid (?), and them iterate through columns of the data grid.
Avatar of Kiran_M
Kiran_M

ASKER

I apologize for the late response. I was able to check the column value  by doing

e.Item.Cells[ColPos].Text != "0"

The downside to this is - if i add new column to the grid before this column then ColPos has to be changed. This is NOT the best solution, but it works fine.

I wanted to get the rowcolumn by name, i am not able get it to work.