展开全部
aspx页面
LinkButton 包含在datalist中
<asp:LinkButton ID="lbtnDelete" runat="server"OnCommand="lbtnDelete_Command" Style="position:relative" CommandArgument='<%#DataBinder.Eva(Container.DataItem,"ID")%>'>删除</asp:LinkButton>
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("<script>alert('删除成功!');window.location=window.location;</script>");
}
else
{
Response.Write("<script>alert('删除失败!');window.location=window.location;</script>");
}
}
LinkButton 包含在datalist中
<asp:LinkButton ID="lbtnDelete" runat="server"OnCommand="lbtnDelete_Command" Style="position:relative" CommandArgument='<%#DataBinder.Eva(Container.DataItem,"ID")%>'>删除</asp:LinkButton>
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("<script>alert('删除成功!');window.location=window.location;</script>");
}
else
{
Response.Write("<script>alert('删除失败!');window.location=window.location;</script>");
}
}
展开全部
aspx页面
LinkButton
包含在datalist中
<asp:LinkButton
ID="lbtnDelete"
runat="server"OnCommand="lbtnDelete_Command"
Style="position:relative"
CommandArgument='<%#DataBinder.Eva(Container.DataItem,"ID")%>'>删除</asp:LinkButton>
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("<script>alert('删除成功!');window.location=window.location;</script>");
}
else
{
Response.Write("<script>alert('删除失败!');window.location=window.location;</script>");
}
}
LinkButton
包含在datalist中
<asp:LinkButton
ID="lbtnDelete"
runat="server"OnCommand="lbtnDelete_Command"
Style="position:relative"
CommandArgument='<%#DataBinder.Eva(Container.DataItem,"ID")%>'>删除</asp:LinkButton>
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("<script>alert('删除成功!');window.location=window.location;</script>");
}
else
{
Response.Write("<script>alert('删除失败!');window.location=window.location;</script>");
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询