Datalist控件EditItemTemplate问题,救命!

来源:百度知道 编辑:UC知道 时间:2024/05/30 18:48:23
比如在datalist1中的ItemTemplate中放一个按扭,点之后要求出现EditItemTemplate模块,请问代码怎么写
如果我把这个按扭的commandName设置为edit,代码如下
protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)
{
//设置DataList1控件的编辑项的索引为选择的当前索引
DataList1.EditItemIndex = e.Item.ItemIndex;
//数据绑定
Bind();
}
对吗?我照书做可是做不出 郁闷死了 请大侠们教教 在线等
可是web develop 2008里datalist编辑模式下有item template模块 edit template模块了 还要添加?怎么甜加?代码我不懂 我是用加控件的方式做的

你要添加一个EditTemplate模块的~~
就是在前台页面上增加一个如下的模块
<asp:DataList ID="DataList1" runat="server" RepeatDirection="Horizontal" RepeatColumns="3"
DataKeyField="CustomerID" DataSourceID="DataListCustomerDataSources" CellPadding="4"
ForeColor="#333333" OnEditCommand="DataList1_EditCommand" OnCancelCommand="DataList1_CancelCommand"
OnUpdateCommand="DataList1_UpdateCommand" OnDeleteCommand="DataList1_DeleteCommand">
<ItemTemplate>
CustomerID:
<asp:Label ID="CustomerIDLabel" runat="server" Text='<%# Eval("CustomerID") %>'>
</asp:Label><br />
CompanyName:
<asp:Label ID="CompanyNameLabe