我在内部gridview中创建了动态文本框,这是在下拉列表中生成的,所选索引已更改,但现在我想在数据库中保存该文本框值,但是如何?有一行有五个动态文本框现在如何获取该值在提交按钮点击每一行任何人都可以帮助我
<asp:GridView ID="GridViewclass" runat="server" OnRowDataBound="GridViewclass_RowDataBound"
OnDataBound="GridViewclass_DataBound"
AutoGenerateColumns="False" AutoGenerateSelectButton="true"
HeaderStyle-BackColor="#174A63" HeaderStyle-ForeColor="white" AllowPaging="true" Font-Size="14px"
Style="margin-left: 16%;" PageSize="15" Width="300px">
<SelectedRowStyle CssClass="selectedRowStyle" />
<Columns>
<asp:BoundField DataField="RowNumber" HeaderText="Row Number" />
<asp:TemplateField HeaderText="Header 1">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Header 2">
<ItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Header 3">
<ItemTemplate>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Header 4">
<ItemTemplate>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Header 5">
<ItemTemplate>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
//代码隐藏
protected void ddlClassUnits_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
int createrows = 0;
int GroupId = Convert.ToInt32(ddlClassUnits.SelectedValue);
if (GroupId == 0)
{
ClearContentControls(4);
}
else
{
if (GroupId == 1)
{
createrows = 1;
}
if (GroupId == 2)
{
createrows = 2;
}
GridViewclass.Visible = true;
DataTable dt = new DataTable();
DataRow dr = null;
dt.Columns.Add(new DataColumn("RowNumber", typeof(string)));
dt.Columns.Add(new DataColumn("Column1", typeof(string)));
dt.Columns.Add(new DataColumn("Column2", typeof(string)));
dt.Columns.Add(new DataColumn("Column3", typeof(string)));
dt.Columns.Add(new DataColumn("Column4", typeof(string)));
dt.Columns.Add(new DataColumn("Column5", typeof(string)));
for (int i = 0; i < createrows; i++)
{
dr = dt.NewRow();
dr["RowNumber"] = i + 1; ;
dr["Column1"] = string.Empty;
dr["Column2"] = string.Empty;
dr["Column3"] = string.Empty;
dr["Column4"] = string.Empty;
dr["Column5"] = string.Empty;
dt.Rows.Add(dr);
}
GridViewclass.DataSource = dt;
GridViewclass.DataBind();
ViewState["CurrentTable"] = dt;
}
}
catch (Exception ex)
{
}
}
现在如何在提交按钮单击
中获取动态文本框值