您好,登錄后才能下訂單哦!
前臺:
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound">
<ItemTemplate>
<ul>
<li>
<%#Eval("DepId")%>
<%#Eval("Name")%></li></ul>
<asp:Repeater ID="Repeater2" runat="server">
<ItemTemplate>
<asp:CheckBox ID="cb" runat="server" Text='<%#Eval("RealName")%>' />
<asp:HiddenField ID="hidId" Value='<%#Eval("UserId")%>' runat="server" />
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
后臺:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
CF.Model.Department modelDepartment = new CF.Model.Department();
CF.BLL.Department bllDepartment = new CF.BLL.Department();
DataSet ds = bllDepartment.GetAllList();
Repeater1.DataSource = ds.Tables[0].DefaultView;
Repeater1.DataBind();
}
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rp = (Repeater)e.Item.FindControl("Repeater2");
string id = DataBinder.Eval(e.Item.DataItem, "DepId")。ToString(); //取得部門id
//根據當前部門的id從人員表中查找員工的數據
CF.Model.Users modelUsers = new CF.Model.Users();
CF.BLL.Users bllUsers = new CF.BLL.Users();
DataSet dsUsers = bllUsers.GetList("DepId=" + id);
rp.DataSource = dsUsers.Tables[0].DefaultView;
rp.DataBind();
}
}
//提交培訓名單
protected void btnSubmit_Click(object sender, EventArgs e)
{
string trainPersonsId="";
string trainPersonsNames="";
for (int i = 0; i < this.Repeater1.Items.Count; i++)
{
Repeater rptPersons = (Repeater)this.Repeater1.Items[i].FindControl("Repeater2");
for (int j = 0; j < rptPersons.Items.Count; j++)
{
int id = Convert.ToInt32(((HiddenField)rptPersons.Items[j].FindControl("hidId"))。Value);
CheckBox cb = (CheckBox)rptPersons.Items[j].FindControl("cb");
if (cb.Checked)
{
trainPersonsId += id + ",";
trainPersonsNames += cb.Text.Trim() + ",";
}
}
//foreach (RepeaterItem item in rptPersons.Items)
//{
// if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
// {
// CheckBox cb = item.FindControl("cb") as CheckBox;
// if (cb.Checked)
// {
// trainPersonsNames += cb.Text + "|";
// }
// }
}
if (trainPersonsId != "")
{
//去除最后一個字符
trainPersonsId = trainPersonsId.Substring(0, trainPersonsId.Length - 1);
}
if (trainPersonsNames != "")
{
//去除最后一個字符
trainPersonsNames = trainPersonsNames.Remove(trainPersonsNames.Length - 1);
}
Response.Redirect("add.aspx?trainPersonsId=" + trainPersonsId + "&&trainPersonsNames=" + trainPersonsNames);
//JscriptMsg("提交成功啦!", "add.aspx?trainPersonsId=" + trainPersonsId + "&&trainPersonsNames=" + trainPersonsNames, "Success");
//JscriptMsg("審核通過成功啦!", Utils.CombUrlTxt("list.aspx", "channel_id={0}&keywords={1}&property={2}",
// this.channel_id.ToString(), this.keywords, this.property), "Success");
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。