我在datagrid中添加了兩列按鈕列,可是我現在不能判定我究竟按下的是該行的那個按鈕?
注:這兩列應為其他原因所以用的不是edit列,而是itemtemplate中添加的button。那位高手能屆決,絕對感激!!

解决方案 »

  1.   

    给你的Button的CommandName分别指定值
    在Item_Command事件里面判断
    if(e.CommandName = "xxx")
    ..........
      

  2.   

    给两个按钮的 CommandName 属性指定两个值,如:cmdEdit 和  cmdDel
    然后在 Item_Command 事件里判断:如下:private void Item_Command(....)
    {
        if(e.CommandName == "cmdEdit")
        {
             //your edit code here
        }
        else if(e.CommandName == "cmdDel")
        {
            //your delete code here
        }
    }
      

  3.   

    asp:Button ID=bu1 Runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"view")%>' CommandName="view">
    </asp:Button>
    asp:Button ID=bu2 Runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"down")%>' CommandName="down">
    </asp:Button>在ItemCommand事件中
    if(e.CommandName=="view")
    {
    //第一个按钮
    }
    else
    //第二个按钮