1 <div id="Process">
2 <%BLL.Right.RoleRight bll = new BLL.Right.RoleRight();
3 if (!(bll.SeachApp().Rows.Count > 0))
4 {%>
5 <span>审批流程设定</span>
6 <asp:DropDownList ID="ddlDepN" runat="server">
7 </asp:DropDownList>
8 <%} %>
9 <asp:HiddenField ID="hfApp" runat="server" />
10 <div>
11 <asp:Repeater ID="rptApp" runat="server" OnItemCommand="rptApp_ItemCommand" OnItemDataBound="rptApp_ItemDataBound">
12 <ItemTemplate>
13 <div id="a">
14 <span>审批流程设定</span>
15
16 <asp:DropDownList ID="ddlDepN" runat="server">
17 </asp:DropDownList>
18 </div>
19 </ItemTemplate>
20 </asp:Repeater>
21 </div>
22 </div>
表中没数据的时候克隆的是ddlDepN这个控件。当有数据的时候克隆就是Repeater的下拉框了。
$("#btnAdd").click(function() {
// alert($('#hfApp').val());
// alert("d");
// $("#ddlDepOne").clone(true).insertAfter("#ddlDepOne");
// $("#Process").clone(true).insertAfter("#ddlDepOne");
var ddlTag = document.getElementsByTagName("select");
var ddlId;
// ddlId = document.getElementById("ddlDepN");
// if (ddlTag.length < ddlId.length) {
// $("#add").append("<div><span>审批流程设定</span><select name='companyType'></select></div>");
// } else {
// alert("你已添加完所有具备审批权限的流程");
// }
if ($('#hfApp').val() > 0) {
ddlId = document.getElementById("rptApp_ctl00_ddlDepN");
if (ddlTag.length < ddlId.length) {
$("#a").clone(true).insertAfter("#Process");
} else {
alert("你已添加完所有具备审批权限的流程");
}
} else {
ddlId = document.getElementById("ddlDepN");
if (ddlTag.length < ddlId.length) {
$("#Process").clone(true).insertAfter("#Process");
} else {
alert("你已添加完所有具备审批权限的流程");
}
}
});
JQ代码有写的不对或是不规范的地方请指证。本人JQ很烂。
protected void btnSave_Click(object sender, EventArgs e)
{
if (rrbll.IsAddPro().Rows.Count > 0)
{
//修改(删除后重新添加)
// int
// int ddlcount = rrbll.SeachApp().Rows.Count;
rrbll.DeleteApp();
//获取页面下拉框数量 遍历 重新添加
// int k = rrbll.SeachApp().Rows.Count - 1;
int ddlcount = 0;
//foreach (Control ctl in this.Form.Controls)
//{
// if (ctl is DropDownList)
// {
// ddlcount++;
// }
//}
foreach (RepeaterItem item in rptApp.Items)
{
// if()
ddlcount++;
}
for (int i = 0; i < ddlcount; i++)
{
string ddl = Request.Form.GetValues("rptApp$ctl0" +i+ "$ddlDepN")[0];
rrbll.AddRoleRihts(ddl, 1001 + i);
}
string[] mm = Request.Form.GetValues("rptApp_ctl00_ddlDepN");
DropDownList ddlapp =this.Form. FindControl("rptApp_ctl00_ddlDepN") as DropDownList;
int a = ddlapp.Items.Count;
//if (ddlapp.Items.Count>1)
//{
// string[] ddl = Request.Form.GetValues("rptApp_ctl00_ddlDepN");
// for (int i = 1; i < ddl.Length-1; i++)
// {
// rrbll.AddRoleRihts(ddlapp.SelectedValue, 1001 + rrbll.SeachApp().Rows.Count + i);
// }
//}
}
else
{
string[] ddl = Request.Form.GetValues("ddlDepN");
for (int i = 0; i < ddl.Length; i++)
{
rrbll.AddRoleRihts(ddl[i], 1001 + i);
}
}
gvApp.DataSource = rrbll.SeachApp();
gvApp.DataBind();//列表显示(直观)
rptApp.DataSource = rrbll.SeachApp();
rptApp.DataBind();//遍历下拉框显示,便于修改 删除
}
不明白的就是为什么添加操作的时候能通过string[] ddl = Request.Form.GetValues("ddlDepN");获取的到值,而到了修改的时候 string[] mm = Request.Form.GetValues("rptApp_ctl00_ddlDepN");这个就获取不到值了呢?希望高手帮忙解答。。。QQ1032540492. 谢谢!!!
关注中,不用control很久了