</Columns> </asp:GridView>protected void GridViewInfo_RowCommand(object sender, GridViewCommandEventArgs e) { GridView gv = (GridView)sender; if (e.CommandName == "Button_Update") { if (gv.Rows.Count > 0) { int id = 0; int index = 0; WebsiteCore.BLL.BWeddingBudgetCategory bll = new WebsiteCore.BLL.BWeddingBudgetCategory(); WebsiteCore.Model.WeddingBudgetCategory model = new WebsiteCore.Model.WeddingBudgetCategory(); for (int i = 0; i < gv.Rows.Count; i++) { id = Int32.Parse(gv.DataKeys[i].Value.ToString()); index = Int32.Parse(Request["textindex" + id.ToString()]); model.wbgcId = id; model.wbgcIndex = index; bll.UpdateIndex(model); } }
<asp:GridView ID="GridViewInfo" runat="server" AutoGenerateColumns="False" CellPadding="4"
OnRowCommand="GridViewInfo_RowCommand"
SkinID="defaultGridView" Width="100%" DataKeyNames="wbgcid">
<Columns>
<asp:BoundField DataField="wbgcid" HeaderText=" " ReadOnly="True" />
<asp:BoundField DataField="wbgcname" HeaderText="名称 " HeaderStyle-Width="200" />
<asp:TemplateField>
<HeaderTemplate>
序号<asp:Button ID="Button_Update" runat="server" Text="更新序号" CssClass="button" CommandName="Button_Update" />
</HeaderTemplate>
<ItemTemplate>
<input type="text" onkeydown="onlyNum();" name='textindex<%#DataBinder.Eval(Container.DataItem,"wbgcid")%>' value='<%#DataBinder.Eval(Container.DataItem,"wbgcIndex")%>' maxlength="2" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>protected void GridViewInfo_RowCommand(object sender, GridViewCommandEventArgs e)
{
GridView gv = (GridView)sender; if (e.CommandName == "Button_Update")
{
if (gv.Rows.Count > 0)
{
int id = 0;
int index = 0;
WebsiteCore.BLL.BWeddingBudgetCategory bll = new WebsiteCore.BLL.BWeddingBudgetCategory();
WebsiteCore.Model.WeddingBudgetCategory model = new WebsiteCore.Model.WeddingBudgetCategory();
for (int i = 0; i < gv.Rows.Count; i++)
{
id = Int32.Parse(gv.DataKeys[i].Value.ToString());
index = Int32.Parse(Request["textindex" + id.ToString()]);
model.wbgcId = id;
model.wbgcIndex = index;
bll.UpdateIndex(model);
}
}
}
}