Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 806
  • Last Modified:

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.
1 Solution
Anurag ThakurTechnical ManagerCommented:
please go throug msdn link and see if you find what u r looking for
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.
Kiran_MAuthor Commented:
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.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now