datagrid做删除点击删除按钮时。对应的子程序不响应。请问为啥。
<ASP:DATAGRID id="DataGrid1" runat="server" Width="574px" EnableViewState="false" " AutoGenerateColumns="False" onupdatecommand="datagrid1_update" oncancelcommand="datagrid1_cancel" oneditcommand="datagrid1_edit" ondeletecommand="datagrid1_delete" DataKeyField="id">
<Columns>
<ASP:ButtonColumn CommandName="aa" Text="删除" />
<ASP:EditCommandColumn ButtonType="LinkButton" CancelText="取消" EditText="编辑" UpdateText="更新" headertext="操作" />
<ASP:BoundColumn DataField="ID" HeaderText="ID" ReadOnly="true" />
<ASP:BoundColumn DataField="chname" HeaderText="中文名称" />
<ASP:BoundColumn DataField="enname" HeaderText="英文名称" />
<ASP:ButtonColumn DataTextField="sort" HeaderText="序号" />
</Columns>
</ASP:DATAGRID>
-----------------------------------------------------------
 Sub datagrid1_delete(ByVal sender As System.Object, ByVal e As DataGridCommandEventArgs)
    response.redirect("aa.aspx")
end sub

解决方案 »

  1.   

    datagrid上加上OnItemCommand="cn"属性
    下面用commandname属性
    <asp:TemplateColumn HeaderText="响应commandname" runat="server">
    <ItemTemplate>
    <ASP:Button id="cmdinfo1" text="删除" Width="150px" runat="server" CommandName="cn"></ASP:Button>
    </ItemTemplate>
    </asp:TemplateColumn>
    后台
    public void cn(object sender,DataGridCommandEventArgs e)
    {
    if(e.CommandName=="cn")
    {

    }}
      

  2.   

    查查InitializeComponent内事件没有丢失吧。
      

  3.   

    看看 InitializeComponent中的datagrid1_delete事件有没有加载?
      

  4.   

    <ASP:ButtonColumn CommandName="aa" Text="删除" />
    触发ItemCommand事件,比如:
    this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_ItemCommand);
    如果有多个ButtonColumn可以通过CommandName或者CommandArgument区分用户点击了哪个Button
      

  5.   


        '该调用是 Web 窗体设计器所必需的。
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()    End Sub
    这里空的,应该如何写呢
      

  6.   

    http://blog.csdn.net/jaguar1982/archive/2005/01/25/267394.aspx
    MSDN WebCast 讲座下载(Datagrid高级使用技巧)