protected void x2_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList x2 = sender as DropDownList;
GridViewRow r = x2.Parent.Parent as GridViewRow;
if (ViewState["dt"] == null)
{
Response.Write("Error");
return;
}
stoveTable = (DataTable)ViewState["dt"];
stoveTable.Rows[r.RowIndex]["steelKind"] = x2.SelectedValue;
ViewState["dt"] = stoveTable;
this.GridView_list.DataSource = stoveTable;
this.GridView_list.DataBind();
}
protected void x3_TextChanged(object sender, EventArgs e)
{
TextBox x3 = sender as TextBox;
GridViewRow r = x3.Parent.Parent as GridViewRow;
if (ViewState["dt"] == null)
{
Response.Write("Error");
return;
}
stoveTable = (DataTable)ViewState["dt"];
stoveTable.Rows[r.RowIndex]["castingTon"] = x3.Text;
ViewState["dt"] = stoveTable;
this.GridView_list.DataSource = stoveTable;
this.GridView_list.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form runat="server">
<asp:GridView runat="server" ShowFooter="true" AutoGenerateColumns="false"
OnRowDataBound="GridView_list_RowDataBound">
<EmptyDataTemplate>
<table cellspacing="0" rules="all"
>
<tr>
<th scope="col">
选择1
</th>
<th scope="col">
选择2
</th>
<th scope="col">
输入文字
</th>
</tr>
<tr><td>
<asp:DropDownList runat="server">
<asp:ListItem>L0</asp:ListItem>
<asp:ListItem>L1</asp:ListItem>
<asp:ListItem>L2</asp:ListItem>
<asp:ListItem>L3</asp:ListItem>
</asp:DropDownList>
</td><td>
<asp:DropDownList runat="server">
<asp:ListItem>10#</asp:ListItem>
<asp:ListItem>20#</asp:ListItem>
<asp:ListItem>30#</asp:ListItem>
<asp:ListItem>40#</asp:ListItem>
</asp:DropDownList>
</td><td>
<asp:TextBox runat="server"></asp:TextBox>
</td></tr>
</table>
</EmptyDataTemplate>
<Columns>
<asp:TemplateField HeaderText="选择1">
<ItemTemplate>
<asp:DropDownList runat="server" AutoPostBack="true" OnSelectedIndexChanged="x1_SelectedIndexChanged">
<asp:ListItem>L0</asp:ListItem>
<asp:ListItem>L1</asp:ListItem>
<asp:ListItem>L2</asp:ListItem>
<asp:ListItem>L3</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList runat="server">
<asp:ListItem>L0</asp:ListItem>
<asp:ListItem>L1</asp:ListItem>
<asp:ListItem>L2</asp:ListItem>
<asp:ListItem>L3</asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="选择2">
<ItemTemplate>
<asp:DropDownList runat="server" AutoPostBack="true" OnSelectedIndexChanged="x2_SelectedIndexChanged">
<asp:ListItem>10#</asp:ListItem>
<asp:ListItem>20#</asp:ListItem>
<asp:ListItem>30#</asp:ListItem>
<asp:ListItem>40#</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
<FooterTemplate>
<asp:DropDownList runat="server">
<asp:ListItem>10#</asp:ListItem>
<asp:ListItem>20#</asp:ListItem>
<asp:ListItem>30#</asp:ListItem>
<asp:ListItem>40#</asp:ListItem>
</asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="输入文字">
<ItemTemplate>
<asp:TextBox runat="server" AutoPostBack="true" OnTextChanged="x3_TextChanged"></asp:TextBox>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:LinkButton runat="server" Text="添加内容"></asp:LinkButton>
<asp:LinkButton runat="server" Text="删除内容"></asp:LinkButton>
</form>
</body>
</html>