在ASP.NET WEBFORM 中后台实现gridview全选功能

在ASP.NET WEBFORM 中后台实现gridview全选功能_第1张图片

上面是效果图。

 

 

------

前台代码:

OnPageIndexChanging="CardID_PageIndexChanging" Width="1805px" OnRowDataBound="CardID_RowDataBound"
DataKeyNames="tid" OnRowCommand="CardID_RowCommand">













<%#Container.DataItemIndex+1%>





详情



<%-- EditText="详情">

--%>


runat="server">
runat="server">



ItemStyle-HorizontalAlign="Center">


ItemStyle-HorizontalAlign="Center">


ItemStyle-HorizontalAlign="Center">





ItemStyle-HorizontalAlign="Center">


ItemStyle-HorizontalAlign="Center">



<%--


--%>





CommandName="Page" CommandArgument="First">
CommandName="Page" CommandArgument="Prev">
CommandName="Page" CommandArgument="Next">
CommandName="Page" CommandArgument="Last">

---

后台事件:

//全选checkbox事件
protected void chkAll_CheckedChanged(object sender, EventArgs e)
{
for (int i = 0; i < this.CardID.Rows.Count; i++)
{
((CheckBox)CardID.Rows[i].FindControl("chkItem")).Checked =
((CheckBox)this.CardID.HeaderRow.FindControl("chkAll")).Checked;
}
}

//是否上传
protected void Button2_Click(object sender, EventArgs e)
{
#region 选择checkbox验证身份证是否上传的状态
for (int i = 0; i < this.CardID.Rows.Count; i++)
{
CheckBox cb = ((CheckBox)CardID.Rows[i].FindControl("chkItem")) as CheckBox;
string tid = this.CardID.DataKeys[i].Value.ToString();//在datakeyname属性里面设置了tid
if (cb != null && cb.Checked)
{
DataTable dt = DbHelperSQL.QueryDT("select isLoad,receiver_name from tbtrade where tid='" + tid + "'");
if (dt.Rows.Count > 0)
{
try
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://qingguanid.com/api/search.php?n=" + dt.Rows[0]["receiver_name"].ToString());
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
System.Text.Encoding encoding = System.Text.Encoding.GetEncoding("gb2312");
System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream(), encoding);
string htmlstr = reader.ReadToEnd();
reader.Close();
response.Close();
int isload = 0;
if (htmlstr.Contains("not found"))
{
isload = 0;
}
else
{
if (htmlstr.IndexOf(": confirmed") > -1)
{
isload = 1;
}
else
{
isload = 0;
}
}
string sql = @"update tbtrade set isload=" + isload + " where tid='" + tid + "'";
DbHelperSQL.ExecuteSql(sql);
}
catch (Exception error)
{
Response.Write(error.ToString());
}
}
}
}
bind();
#endregion
}

转载于:https://www.cnblogs.com/hbh123/p/5165685.html

你可能感兴趣的:(php)