if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[6].Attributes.Add("onclick", "javascript:return confirm('你确认要删除吗?')");
}
你这样没提示
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Xhhy.MSSQLClass;
using System.Data.SqlClient;
using Xhhy.Function;
using Xhhy.TbClass;
public partial class tieba_mg_Tbapplicamg : System.Web.UI.Page
{
int Certifi;
protected void Page_Load(object sender, EventArgs e)
{
// CheckLogin.isAdminLogin(Request, "/manage/MainLogin.aspx", Response);
System.Text.StringBuilder scriptString = new System.Text.StringBuilder();
scriptString.Append("<script language=JavaScript> ");
scriptString.Append("function DelConfirm() {");
scriptString.Append("return confirm('确认批量删除所选择的吗?');}");
scriptString.Append("</script>");
String js = scriptString.ToString();
if (!IsClientScriptBlockRegistered("DelConfirm"))
{
RegisterClientScriptBlock("DelConfirm", js);
}
this.cmdpiliang.Attributes.Add("onclick", "return DelConfirm()");
}
protected string QqjyTbmaster()
{
string sqlsr = "";
if (TxtTbMasterID.Text.Trim() != "")
{
sqlsr = "SELECT QqjyTbMasters.MastersID, QqjyTbBroad.BroadName, QqjyTbMasters.MastersName, QqjyTbMasters.MastersTime,QqjyTbMasters.Certification FROM QqjyTbMasters INNER JOIN QqjyTbBroad ON QqjyTbMasters.BroadId = QqjyTbBroad.BroadId where MastersID like '%" + this.TxtTbMasterID.Text.Trim() + "%'";
if (TxtTbBroadName.Text.Trim() != "")
sqlsr += " and BroadName like '%" + TxtTbBroadName.Text.Trim() + "%'";
if (TxtTbMasters.Text.Trim() != "")
sqlsr += " and MastersName like '%" + TxtTbMasters.Text.Trim() + "%'";
if (ddlTbCertifi.Text.Trim() != "")
{
if (ddlTbCertifi.SelectedItem.Text.Trim() != "未验证")
{
sqlsr += "and QqjyTbMasters.Certification ='1'";
}
else
{
sqlsr += "and QqjyTbMasters.Certification ='0'";
}
}
if (this.kaishishijian.Value != "" && this.jiesushijian.Value != "")
{
string kaishi = this.kaishishijian.Value.Trim().ToString();
string jieshu = this.jiesushijian.Value.Trim().ToString();
sqlsr += "and MastersTime BETWEEN '" + kaishi + "' and '" + jieshu + "' ";
}
}
else if (TxtTbBroadName.Text.Trim() != "")
{
sqlsr = "SELECT QqjyTbMasters.MastersID,QqjyTbBroad.BroadName, QqjyTbMasters.MastersName,QqjyTbMasters.MastersTime,QqjyTbMasters.Certification FROM QqjyTbMasters INNER JOIN QqjyTbBroad ON QqjyTbMasters.BroadId = QqjyTbBroad.BroadId where BroadName like '%" + this.TxtTbBroadName.Text.Trim() + "%'";
if (TxtTbMasters.Text.Trim() != "")
sqlsr += " and MastersName like '%" + TxtTbMasters.Text.Trim() + "%'";
if (ddlTbCertifi.Text.Trim() != "")
{
if (ddlTbCertifi.SelectedItem.Text.Trim() != "未验证")
{
sqlsr += "and QqjyTbMasters.Certification ='1'";
}
else
{
sqlsr += "and QqjyTbMasters.Certification ='0'";
}
}
if (this.kaishishijian.Value != "" && this.jiesushijian.Value != "")
{
string kaishi = this.kaishishijian.Value.Trim().ToString();
string jieshu = this.jiesushijian.Value.Trim().ToString();
sqlsr += "and MastersTime BETWEEN '" + kaishi + "' and '" + jieshu + "' ";
}
}
else if (TxtTbMasters.Text.Trim() != "")
{
sqlsr = "SELECT QqjyTbMasters.MastersID, QqjyTbBroad.BroadName, QqjyTbMasters.MastersName, QqjyTbMasters.MastersTime,QqjyTbMasters.Certification FROM QqjyTbMasters INNER JOIN QqjyTbBroad ON QqjyTbMasters.BroadId = QqjyTbBroad.BroadId where MastersName like '%" + this.TxtTbMasters.Text.Trim() + "%'";
if (ddlTbCertifi.Text.Trim() != "")
{
if (ddlTbCertifi.SelectedItem.Text.Trim() != "未验证")
{
sqlsr += "and QqjyTbMasters.Certification ='1'";
}
else
{
sqlsr += "and QqjyTbMasters.Certification ='0'";
}
}
if (this.kaishishijian.Value.Trim() != "" && this.jiesushijian.Value.Trim() != "")
{
string kaishi = this.kaishishijian.Value.Trim().ToString();
string jieshu = this.jiesushijian.Value.Trim().ToString();
sqlsr += "and MastersTime BETWEEN '" + kaishi + "' and '" + jieshu + "' ";
}
}
else if (ddlTbCertifi.Text.Trim() != "")
{
if (ddlTbCertifi.SelectedItem.Text.Trim() != "未验证")
{
sqlsr = "SELECT QqjyTbMasters.MastersID, QqjyTbBroad.BroadName, QqjyTbMasters.MastersName, QqjyTbMasters.MastersTime,QqjyTbMasters.Certification FROM QqjyTbMasters INNER JOIN QqjyTbBroad ON QqjyTbMasters.BroadId = QqjyTbBroad.BroadId where QqjyTbMasters.Certification='1'";
}
else
{
sqlsr = "SELECT QqjyTbMasters.MastersID, QqjyTbBroad.BroadName, QqjyTbMasters.MastersName, QqjyTbMasters.MastersTime,QqjyTbMasters.Certification FROM QqjyTbMasters INNER JOIN QqjyTbBroad ON QqjyTbMasters.BroadId = QqjyTbBroad.BroadId where QqjyTbMasters.Certification='0'";
}
if (this.kaishishijian.Value != "" && this.jiesushijian.Value != "")
{
string kaishi = this.kaishishijian.Value.Trim().ToString();
string jieshu = this.jiesushijian.Value.Trim().ToString();
sqlsr += "and MastersTime BETWEEN '" + kaishi + "' and '" + jieshu + "' ";
}
}
else if (this.kaishishijian.Value != "" && this.jiesushijian.Value != "")
{
string kaishi = this.kaishishijian.Value.Trim().ToString();
string jieshu = this.jiesushijian.Value.Trim().ToString();
sqlsr = "SELECT QqjyTbMasters.MastersID, QqjyTbBroad.BroadName, QqjyTbMasters.MastersName, QqjyTbMasters.MastersTime,QqjyTbMasters.Certification FROM QqjyTbMasters INNER JOIN QqjyTbBroad ON QqjyTbMasters.BroadId = QqjyTbBroad.BroadId where MastersTime BETWEEN '" + kaishi + "' and '" + jieshu + "'";
}
else
{
sqlsr = "SELECT QqjyTbMasters.MastersID, QqjyTbBroad.BroadName, QqjyTbMasters.MastersName, QqjyTbMasters.MastersTime,QqjyTbMasters.Certification FROM QqjyTbMasters INNER JOIN QqjyTbBroad ON QqjyTbMasters.BroadId = QqjyTbBroad.BroadId";
}
this.SqlDataSource1.SelectCommand = sqlsr;
return sqlsr;
}
protected void BbtnSearch_Click(object sender, EventArgs e)
{
this.QqjyTbmaster();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[6].Attributes.Add("onclick", "javascript:return confirm('你确认要删除吗?')");
}
}
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
((CheckBox)row.Cells[0].FindControl("xxx")).Checked = true;
}
}
protected void cmdpiliang_Click1(object sender, EventArgs e)
{
for (int row = 0; row < this.GridView1.Rows.Count; row++)
{
if (((CheckBox)this.GridView1.Rows[row].Cells[0].FindControl("xxx")).Checked == true)
{
int id = Convert.ToInt32(this.GridView1.DataKeys[row].Value);
string sqlstr = "delete from QqjyTbMasters where MastersID = " + id;
Database.ExecuteSql(sqlstr);
}
}
this.GridView1.DataBind();
}
protected void cmdquxiao_Click1(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
((CheckBox)row.Cells[0].FindControl("xxx")).Checked = false;
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
}
protected void SqlDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
string sqlsr = this.QqjyTbmaster();
SqlDataSource1.SelectCommand = sqlsr;
}
}
我的全部代码是这样的 红色的代码是我用来判断的