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

Posted on 2009-04-15
Last Modified: 2012-05-06
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.
Question by:Kiran_M
    LVL 26

    Accepted Solution

    please go throug msdn link and see if you find what u r looking for
    LVL 29

    Expert Comment

    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.

    Author Closing Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Title # Comments Views Activity
    .NET Installer Recommendation 3 50
    linq to SQL UPDATE and Verify 6 36
    What are the big features of MVC5? 4 30
    Change to event 1 47
    Article by: Ivo
    Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
    In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now