1.在Repeater的ItemDataBound事件中绑字数据项的值
protected void rpt_list_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
DataRowView gv = (DataRowView)e.Item.DataItem;
Response.Write(gv["RoleName"].ToString());
}
2.遍历checkbox项
foreach (RepeaterItem ritem in rpt_list.Items)
{
CheckBox chk = (CheckBox)ritem.FindControl("chkRoleID");
Label lbl = (Label)ritem.FindControl("lblRoleID");
if (chk.Checked)
{
TextBox1.Text += lbl.Text;
}
}
3.全选checkbox
<input id="chkAll" type="checkbox" οnclick="SelectAllCheckBox(this)" />
function SelectAllCheckBox(e)
{
var form =document.forms[0];
for(i=0;i<form.elements.length;i++)
{
if(form.elements[i].type=="checkbox")
{
form.elements[i].checked= e.checked;
}
}
}