在GridView里,有如下CommandName:delete、edit、update、cancel。
现在我想在GridView实现这样的功能:点某按钮,实现类似update的功能,但是update已经被其他按钮用了。
不知有什么方法实现?
比较急,请各位帮帮忙。
现在我想在GridView实现这样的功能:点某按钮,实现类似update的功能,但是update已经被其他按钮用了。
不知有什么方法实现?
比较急,请各位帮帮忙。
1.按钮的CommandName="xxx"
2.在GridView的 ItemCommand事件中 捕获所有的ItemCommand 比较是否等与xxx 以调用自定义函数其他 还可以使用CommandArgument作为参数
GridView.RowCommand 事件
http://msdn2.microsoft.com/zh-cn/library/system.web.ui.webcontrols.gridview.rowcommand(VS.80).aspx
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button2" runat="server" CommandName="YourCommandName" Text="Button" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
if(e.CommandName=="name")
就OK了
OnRowCommand="GridView1_RowCommand"2:
<asp:LinkButton ID="LinkButton3" CommandName="moveUp" runat="server" Text="向上移动"></asp:LinkButton>3:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "moveUp")
{
sortMoveUp();
}
} private void sortMoveUp()
{
……
}谢谢各位!