asp.net gridview rowcommand事件
想要的效果就是点击删除按钮,弹出一个隐藏层,在层内输入密码并验证正确后,删除相应的记录
现在是点击删除后一闪,能看到div层 然后就直接提示密码错误,跳转到gridview列表
<asp:ImageButton CommandArgument='<%#Eval("id") %>' CommandName='Del' OnClientClick="showDiv()" ID="ImageButton1" runat="server" ImageUrl="images/gtk-del.png" AlternateText="删除" />
层
<div id="popDiv" class="mydiv" style="display:none;">
密码:<asp:TextBox ID="TextBox1" runat="server" TextMode="Password" ></asp:TextBox>
<br />
<asp:Button ID="BttLogin" runat="server" Text=" 提 交 " OnClick="BttLogin_Click" />
<asp:Button ID="Button1" runat="server" Text=" 取 消 " OnClientClick="closeDiv()" />
</div>
后台代码
if (e.CommandName == "Del")
{
string username = HttpUtility.HtmlDecode(Response.Cookies["adminName"].Value);
string strSQL2 = "select * from admin where uname = '" + username + "' and pwd = '" + cls.MD5(TextBox1.Text.Trim()) + "'";
DataTable dt2 = cls.GetDataTable(strSQL2);
if (dt2.Rows.Count > 0)
{
DataTable dt = cls.GetDataTable("SELECT * FROM list WHERE id = '" + e.CommandArgument.ToString() + "')");
dt.Dispose();
string strSQL = "Delete From list Where id = " + e.CommandArgument;
if (cls.GetSQLExecuteRows(strSQL) != -1)
{
cls.MsgBox("信息删除成功!");
}
else
{
cls.MsgBox("出现错误!", "Back");
}
&nb