aspx页面
LinkButton 包含在datalist中
aspx.cs 页面
protected void lbtnDelete_Command(object sender, CommandEventArgs e)
{
//string userID = Request.QueryString["userID"]; //不好传送,试了N遍
string userID = e.CommandArgument.ToString();
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = db.createCon();
cmd.CommandText = "delete from guest where ID='"+userID+"'";
if (cmd.ExecuteNonQuery() > 0)
{
Response.Write("");
}
else
{
Response.Write("");
}
}
直接写sql语句就行了!
这么抠?
aspx页面
LinkButton
包含在datalist中
runat="server"OnCommand="lbtnDelete_Command"
Style="position:relative"
CommandArgument='<%#DataBinder.Eva(Container.DataItem,"ID")%>'>删除
aspx.cs
页面
protected
void
lbtnDelete_Command(object
sender,
CommandEventArgs
e)
{
//string
userID
=
Request.QueryString["userID"];
//不好传送,试了N遍
string
userID
=
e.CommandArgument.ToString();
OleDbCommand
cmd
=
new
OleDbCommand();
cmd.Connection
=
db.createCon();
cmd.CommandText
=
"delete
from
guest
where
ID='"+userID+"'";
if
(cmd.ExecuteNonQuery()
>
0)
{
Response.Write("");
}
else
{
Response.Write("");
}
}