在GridView里,有如下CommandName:delete、edit、update、cancel。
现在我想在GridView实现这样的功能:点某按钮,实现类似update的功能,但是update已经被其他按钮用了。
不知有什么方法实现?
比较急,请各位帮帮忙。

解决方案 »

  1.   

    可以 
    1.按钮的CommandName="xxx"
    2.在GridView的 ItemCommand事件中 捕获所有的ItemCommand 比较是否等与xxx 以调用自定义函数其他 还可以使用CommandArgument作为参数
      

  2.   

    拽个 BUtton 到模板列中,设置 CommandName然后在 GridView_RowCommand 中处理
      

  3.   

    实例见
    GridView.RowCommand 事件
    http://msdn2.microsoft.com/zh-cn/library/system.web.ui.webcontrols.gridview.rowcommand(VS.80).aspx
      

  4.   

    可以...用Commandname来区别//
      

  5.   

    <asp:GridView ID="GridView1" runat="server" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP:300px" AutoGenerateColumns="False">
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Button ID="Button2" runat="server" CommandName="YourCommandName" Text="Button" />
                        </ItemTemplate>
                    
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
      

  6.   

    只要不用这几个名字,随便那一个,然后在ItemCommand里面处理就行了
      

  7.   

    主要在在界面里写一个CommandName 在代码里的ItemCommand事件里写上
    if(e.CommandName=="name")
    就OK了
      

  8.   

    1:
    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()
        {
            ……
        }谢谢各位!