DATAGRID的OnItemCommand是不是不可以激发模板列?
搞了两天,没搞出来,发了两张贴石沉大海,为什么ImageButton按下去没有反应?
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<P>
<asp:Label id="Label1" runat="server" EnableViewState="False">Label</asp:Label></P>
<P><FONT face="宋体"></FONT> </P>
<P>
<asp:DataGrid id="DataGrid1" runat="server" OnItemCommand="ItemsGrid_Command">
<Columns>
<asp:TemplateColumn HeaderText="上移">
<ItemTemplate>
<center>
<asp:ImageButton CommandName="Up" Runat="server" ID="Imagebutton1" ImageUrl="/Adminuser/images/up.gif"></asp:ImageButton>
</center>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid></P>
</form>
</body>
后台页
public void ItemsGrid_Command(Object sender, DataGridCommandEventArgs e)
{
switch(e.CommandName)
{
case "Up":
this.Label1.Text="ok";
break;
default:
// Do nothing.
break;
}
}
已经确定,事件肯定有写,因为在后面加上一列:
<asp:ButtonColumn Text="Up" CommandName="Up"></asp:ButtonColumn>
马上就可以了,好象模板列不可以用一样