Datalist中 DataKeyField 的用法
前台:
<asp:DataList ID="datalist" ondeletecommand="datalist_DeleteCommand" DataKeyField="id">
在绑定控件<asp:LinkButton ID="likbtnDel" runat="server" CommandName="Delete">删除</asp:LinkButton>
后台:
protected void datalist_DeleteCommand(object source, DataListCommandEventArgs e)
{
int index = e.Item.ItemIndex;
string id = this.datalist.DataKeys[index].ToString();
}
经验在于积累----武二郎