问题描述
求大神求教
解决方案
解决方案二:
这个要在DataList1的时间去做
解决方案三:
foreach(CheckBoxiteminDataList1.checkeditems)?
解决方案四:
asp.net用复选框删除数据的一、复选框设置<asp:GridViewID="ClassList"runat="server"AutoGenerateColumns="False"CellPadding="4"Font-Size="11pt"GridLines="None"Width="468px"OnRowCancelingEdit="ClassList_RowCancetingEdit"OnRowDeleting="ClassList_RowDeleting"OnRowEditing="ClassList_RowEditing"OnRowUpdating="ClassList_RowUpdating"ForeColor="#333333"AllowPaging="True"AllowSorting="True"OnPageIndexChanging="ClassList_PageIndexChangging"PageSize="6"OnRowDataBound="ClassList_RowDataBound"><FooterStyleBackColor="#1C5E55"Font-Bold="True"ForeColor="White"/><Columns><asp:TemplateFieldHeaderText="选项"><ItemTemplate><asp:CheckBoxID="CheckBox1"runat="server"Font-Size="9pt"Height="1px"Width="1px"/></ItemTemplate></asp:TemplateField><asp:BoundFieldDataField="ST_c_id"HeaderText="类型编号"ReadOnly="True"/><asp:BoundFieldDataField="ST_c_name"HeaderText="文章类别"/><asp:CommandFieldHeaderText="编辑"ShowEditButton="True"/><asp:CommandFieldHeaderText="删除"ShowDeleteButton="True"/></Columns>//codego.net/11/1/1/<SelectedRowStyleBackColor="#C5BBAF"ForeColor="#333333"Font-Bold="True"/><PagerStyleBackColor="#666666"ForeColor="White"HorizontalAlign="Center"/><HeaderStyleBackColor="#1C5E55"Font-Bold="True"ForeColor="White"/><AlternatingRowStyleBackColor="White"/><RowStyleBackColor="#E3EAEB"/><EditRowStyleBackColor="#7C6F57"/></asp:GridView二、绑定数据行删除复选框数据SqlDataMy_sqldata=newSqlData();SqlConnectionST_myConn;protectedvoidPage_Load(objectsender,EventArgse){//建立数据库连接stringST_dns=ConfigurationSettings.AppSettings["conStr"];ST_myConn=newSqlConnection(ST_dns);if(!IsPostBack){//调用自定义方法ST_Type_List_Bind()进行数据绑定ST_Type_List_Bind();/*判断是否登录*/ST_check_Login();}}//加载文章类型的信息publicvoidST_Type_List_Bind(){stringsqlstr="select*fromST_classorderbyST_datedesc";//调用公共类中的ExceDS()方法,用来返回一个DataSet类型My_sqldata.ExceDS(sqlstr);//获取数据表中的主键字段ClassList.DataKeyNames=newstring[]{"ST_c_id"};ClassList.DataSource=My_sqldata.ExceDS(sqlstr);ClassList.DataBind();}protectedvoidCheckBox2_CheckedChanged(objectsender,EventArgse){for(inti=0;i<=ClassList.Rows.Count-1;i++){CheckBoxcbox=(CheckBox)ClassList.Rows[i].FindControl("CheckBox1");if(CheckBox2.Checked==true){cbox.Checked=true;}else{cbox.Checked=false;}}}protectedvoidButton3_Click(objectsender,EventArgse){CheckBox2.Checked=false;for(inti=0;i<=ClassList.Rows.Count-1;i++){CheckBoxcbox=(CheckBox)ClassList.Rows[i].FindControl("CheckBox1");cbox.Checked=false;}}protectedvoidButton2_Click(objectsender,EventArgse){//ST_myConn.Open();for(inti=0;i<=ClassList.Rows.Count-1;i++){CheckBoxcbox=(CheckBox)ClassList.Rows[i].FindControl("CheckBox1");if(cbox.Checked==true){stringsqlstr="deletefromST_classwhereST_c_id='"+ClassList.DataKeys[i].Value+"'";My_sqldata.ExceSQL(sqlstr);Response.Write("<scriptlanguage=javascript>alert('批量删除成功!');location='BlogType.aspx'</script>");}}}
解决方案五:
你這樣不就是有複選了嗎@@?還是你問的是這個<thwidth="7%"><inputid="ChkAll"value="chkall"type="checkbox"onclick="Check(this)">全選</th><scriptlanguage="JavaScript"type="text/javascript">functionCheck(parentCHK){elm=document.forms[0];for(i=0;i<=elm.length-1;i++){if(elm[i].type=="checkbox"&&elm[i].id!=parentCHK.id){if(elm.elements[i].checked!=parentCHK.checked)elm.elements[i].click();}}}</script>