62,046
社区成员
发帖
与我相关
我的任务
分享
<asp:DataList ID="CondimentDataList" DataSourceID="SqlDataSource2"
DataKeyField="CondimentName"
runat="server">
<ItemTemplate>
<input type="checkbox" id='<%# Eval("CondimentID") %>' class="regular-checkbox big-checkbox" runat="server" /><label for='<%# Eval("CondimentID") %>' />
<asp:Label ID="lblCondimentName" CssClass="txtcondimentname" Text='<%# Eval("CondimentName") %>' runat="server" />
</ItemTemplate>
</asp:DataList>
iRowCount = CondimentDataList.Items.Count
For iCtr = 0 To iRowCount - 1
tempChk = CondimentDataList.Items(iCtr).FindControl("chkSelect")
If tempChk.Checked = True Then
If sCondiment = "" Then
sCondiment = CondimentDataList.DataKeys(iCtr).ToString()
Else
sCondiment = sCondiment & "," & CondimentDataList.DataKeys(iCtr).ToString()
End If
End If
Next iCtr
<input type="checkbox" id="chkSelect" class="regular-checkbox big-checkbox" runat="server" /><label runat="server" for="chkSelect" ></label>
<asp:Label ID="lblCondimentName" CssClass="txtcondimentname" Text='<%# Eval("CondimentName") %>' runat="server" />
我现在改成这个,通过chkSelect能找的到控件,但是<label runat="server" for="chkSelect" ></label>
for="chkSelect" 要改成CondimentDataList_chkSelect_0 ---100
这个在显示的时候JAVASCRIPT怎么写?foreach (DataListItem dlt in DataList1.Items) //循环取出DataList里的每一项
{
//用DataListItem的FindControl方法找到CheckBox,参数为CheckBox的ID,返回为Control类型,将其转换成CheckBox
CheckBox ckb = (CheckBox)dlt.FindControl("cbDelete");
if (ckb.Checked) //判断CheckBox是否选中
{
int id = Convert.ToInt32(DataList1.DataKeys[dlt.ItemIndex]); //取出DataList该项的主键,用于数据库删除操作
PostOperate po = new PostOperate(); //实例化封装的数据操作类
flag = po.Delete(id); //执行类中的Delete方法删除数据,删除成功则返回True,如果没有删除数据,flag为false
}
}
protected void btnDelete_Click1(object sender, EventArgs e)
{
for (int i = 0; i <= dlstProType.Items.Count - 1; i++)
{
CheckBox cbox = (CheckBox)dlstProType.Items[i].FindControl("CheckBox1");
if (cbox.Checked == true)
{
int id = Convert.ToInt32(dlstProType.DataKeys[i]);
RJobType rjobtype = new RJobType();
rjobtype.Delete(id);
ijob.Delete("U_Resume", id, "TalentType");
ijob.Delete("C_Job", id, "TypeID");
}
}
Bind();
}
foreach(Checkbox chk in CondimentDataList.Items(iCtr))
{
if(chk.checked==true)
{
XXX
}
}