Lake County .NET Users' Group Helping the .NET developers of Lake County, Illinois

All posts

Find the cell in a GridViewRow that owns a given control

Kurt Schroeder shares this gem to show how to find a given control ID in a GridViewRow:

    public static int GetCellPosition(GridViewRow gvr, string ctrlID)

    {

        for (int i = 0; i < gvr.Cells.Count; i++)

        {

            foreach (Control c in gvr.Cells[i].Controls)

            {

                if (c.ID == ctrlID)

                    return i;

            }

        }

        return -1;

    }

 

Facebook DZone It! Digg It! StumbleUpon Technorati Del.icio.us NewsVine Reddit Blinklist Furl it!

Post a comment!