8
Answers

get tex box value inside gridview

I have placed GridView1 inside a panel in .aspx file.

here is my code behind...

foreach (GridViewRow gvrC in GridView1.Rows)
        {
            if (gvrC.Visible)
            {
                for (int x = 2; x < GridView1.Columns.Count; x++)
                {
                    foreach (Control cc in gvrC.Cells[x].Controls)
                    {
                        string str = ((TextBox)cc).Text;
                        //my code here. I want to display textbox value
                    }
                }
            }
        }

but it is not entering the 2nd foreach() loop.
plz give me the solution.
Thank You.
Answers (8)