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.
shibasankar beheraPosted Oct 4, 2013, 8:17 AM
thank you
Veena SardaPosted Oct 4, 2013, 8:13 AM
shibasankar beheraPosted Oct 4, 2013, 8:09 AM
I have not given any id for any text boxes...
But i can access the value inside it...
Jignesh TrivediPosted Oct 4, 2013, 8:06 AM
hi,
If you textbox control name is fix than you can also get this textbox using findcontrol method.
for (int i = 0; i < GridView1.Rows.Count; i++)
{
TextBox text = GridView1.Rows[i].FindControl("txtboxName") AS TextBox;
if(text !=null)
{
//Do your code here...
}
}
hope this will help you.
shibasankar beheraPosted Oct 4, 2013, 7:55 AM
Veena SardaPosted Oct 4, 2013, 7:44 AM
shibasankar beheraPosted Oct 4, 2013, 6:39 AM
Veena SardaPosted Oct 4, 2013, 6:33 AM