用DataGrid中的模板列替代编辑按钮列

<asp:TemplateColumn HeaderText="操作">
<ItemTemplate>
<asp:Button ID="editbut" CommandName="Edit" Text="初审" Runat="server"></asp:Button>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="okbut" CommandName="Update" Text="确定" Runat="server"></asp:Button><asp:Button ID="cancelbut" CommandName="Cancel" Text="取消" Runat="server"></asp:Button>
</EditItemTemplate>
</asp:TemplateColumn>

以上的定义和定义编辑按钮列
<asp:EditCommandColumn ButtonType="PushButton" UpdateText="确定" HeaderText="操作" CancelText="取消" EditText="初审"></asp:EditCommandColumn>是一样
datagrid的EditCommand和CancelCommand还有UpdateCommand在两种定义中都是可以调用的(注意红字的CommandName必须这样定义)

这样的定义的好处是可以用FindControl来条用这些按钮。

posted on 2005-05-14 20:52  Ipark  阅读(421)  评论(0编辑  收藏  举报

导航

Creative Commons License
本作品采用知识共享署名 2.5 China许可协议进行许可。