Find Controls inside GridView
// grid view defination
<asp:GridView ID="GridView1"
runat="server"
AutoGenerateColumns="False"
BackColor="PapayaWhip" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" Font-Names="Tahoma" Height="16px"
Width="928px">
<Columns>
<asp:TemplateField>
<HeaderTemplate>HeadingHeaderTemplate>
<ItemTemplate>
<asp:TextBox ID="text_box1"
runat="server">asp:TextBox>
ItemTemplate>
asp:TemplateField>
asp:GridView>
//code for accessing value
of text_box1 inside the GridView1
for(int i = 0;i<GridView1.Rows.Count; i++)
{
TextBox t1;
t1 = (TextBox)GridView1.Rows[n].FindControl("text_box1");
Response.Write(t1.Text);
}
No comments :
Post a Comment