datagrid奇症,高手进来指点
有一个DATAGRID,里面有两列,发现DELETE那列能触发事件响应,但模板列里的UP事件没有响应,是为什么?
<asp:ButtonColumn HeaderText="Delete item" ButtonType="LinkButton" Text="Delete" CommandName="Delete" />
<asp:TemplateColumn HeaderText="上移">
<ItemTemplate>
<center>
<asp:ImageButton CommandName="Up" Runat="server" ImageUrl="/Adminuser/images/up.gif"></asp:ImageButton>
</center>
</ItemTemplate>
</asp:TemplateColumn>
datagrid 的事件是OnItemCommand="ItemsGrid_Command"
代码如下
public void ItemsGrid_Command(Object sender, DataGridCommandEventArgs e)
{
switch(e.CommandName)
{
case "Delete":
this.Label1.Text="del";
break;
// Add other cases here, if there are multiple ButtonColumns in
// the DataGrid control.
case "Up":
this.Label1.Text="up";
break;
default:
// Do nothing.
break;
}
}