复制代码 代码如下:
AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ID"
BorderColor="#333" BorderStyle="solid" BorderWidth="1"
onRowDeleting="PublicGridRowDeleting"
GridLines="None" Width="98%" ForeColor="#333333">
Readonly="True"
Sortexpression="ID" >
CausesValidation="False" CommandName="Delete" onClientClick="return confirm('您确认删
除?');" Text="删除">
日志库暂时为空!
CS代码
复制代码 代码如下:
protected void PublicGridRowDeleting(object sender, GridViewDeleteEventArgs e)
{
string strID = GridLog.DataKeys[e.RowIndex].Value.ToString();//strID就是该行的ID
string strSQL = "Delete from table " +
" WHERe id = " + strID;
//执行删除
Clientscript.RegisterStartupscript(GetType(), "Message", "");
GridBind();
}
关键是设定好DataKeyNames后,可以靠 string strID = GridLog.DataKeys
[e.RowIndex].Value.ToString();获得选择列的ID值 然后用这个ID执行删除就可以了 。



