I have a GridView that is bound to an ObjectDataSource. I add a textbox and a button to each row in the grid to allow the user to enter a date and click the button to subscribe. No field exists in GridView for this textbox and return null refrence when run this page. What should I do? please help.. Here's the ASPX file and the code behind:
<asp:TemplateField HeaderText="content" ItemStyle-Width="150">
<ItemTemplate>
<asp:TextBox ID="Name" runat="server" />
</ItemTemplate>
<ItemStyle Width="150px"></ItemStyle>
</asp:TemplateField>
<asp:ButtonField CommandName="Select" Text="save" ButtonType="Button" />
Code-Behind:
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
GridViewRow row = GridView1.Rows[e.NewSelectedIndex];
string s = row.Cells[0].Text;
//Fetch value of Name.
TextBox tb = (TextBox)GridView1.FindControl("Name");
string name = tb.Text;
}
value of name is null...