if the button belongs to DataGrid's template, set the button's CommandName and/or CommandArgument property

解决方案 »

  1.   

    button不属于datagrid模板的,是在datagrid外的
      

  2.   

    see an example inhttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolsdatagridclassonitemcommandtopic.asp
      

  3.   

    then, why do you want to ItemCommand事件? it is called ItemCommand, i.e., the Command for Itemmove the code in ItemCommand事件 to another method, in your button's Click event handler, call this method
      

  4.   

    我是想这样sub Item_Command(source as object,byval e as DataGridCommandEventArgs)
       Response.write(e.item.text)
    end sub<asp:button id="dd" runat="server" onclick="item_command"></asp:button>但是不行。。报错Public Sub Item_Command(source As Object, e As System.Web.UI.WebControls.DataGridCommandEventArgs)”没有与委托“Delegate Sub CommandEventHandler(sender As Object, e As System.Web.UI.WebControls.CommandEventArgs)”相同的签名。
      

  5.   

    主要是要实现一个功能就是一个button按下后,把datagrid里的每一行的值取出来
      

  6.   

    you cannot do thatsub dd_clicked(source as object,byval e as EventArgs)
       Dim dgi as DataGridItem   for each dgi in DataGrid1.Items
     .....
       nextend sub<asp:button id="dd" runat="server" onclick="dd_clicked"></asp:button>