(1)DataList中添加按钮,并为其添加 CommandArgument属性与CommandName属性...
<asp:Button ID="Button1" runat="server" Text="Button" CommandArgument='<%# Eval("ID") %>' CommandName="del"/>
(2)DataList有个事件OnItemCommand事件,事件在单击DataList控件中的任一按钮时引发...这样在单击当前行的按钮时就会触发事件并获得当前行的ID,进行删除操作啦....
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "del")
{
string strID = e.CommandArgument.ToString();
Response.Write("strID");
}
}
<asp:Button ID="Button1" runat="server" Text="Button" CommandArgument='<%# Eval("ID") %>' CommandName="del"/>
(2)DataList有个事件OnItemCommand事件,事件在单击DataList控件中的任一按钮时引发...这样在单击当前行的按钮时就会触发事件并获得当前行的ID,进行删除操作啦....
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "del")
{
string strID = e.CommandArgument.ToString();
Response.Write("strID");
}
}