

<!--段落-->
<div>
<asp:DataList ID="Menu" runat="server" OnItemDataBound="Menu_ItemDataBound" RepeatDirection="Horizontal">
<ItemStyle VerticalAlign="Top" />
<ItemTemplate>
<div style="float:left; width:120px;">
<div>
<asp:CheckBox ID="opt" runat="server" onClick="onCheck(this);" Text='<%#Eval("MenuName") %>' />
<a href="javascript:;" onclick="onView('<%#Eval("MenuNo") %>')" ><label style="color:Red; line-height:24px;" id="lbl_<%#Eval("MenuNo") %>">展开</label></a>
<div style="margin-left:10px;" id="cont_<%#Eval("MenuNo") %>">
<asp:CheckBoxList runat="server" ID="two_menu" name="two" οnclick="resetOpt(this);">
</asp:CheckBoxList>
</div>
</div>
</div>
</ItemTemplate>
</asp:DataList>
</div>
.cs
1
//
绑定datalist
2
protected
void
BindMenu()
3
{
4
ICollection<Org_SysMenusRecords> fMenu = org_first.getMenu();
5
Menu.DataSource = fMenu;
6
Menu.DataKeyField = "MenuNo";
7
Menu.DataBind();
8
}
9
//
ItemDataBound 事件中绑定checkboxlist
10
rotected
void
Menu_ItemDataBound(
object
sender, DataListItemEventArgs e)
11
{//purview list
12
string parent = Menu.DataKeys[e.Item.ItemIndex].ToString();
13
BindPurview(parent, (CheckBoxList)e.Item.FindControl("two_menu"));
14
}
15
16
protected
void
BindPurview(
string
parent, CheckBoxList bb)
17
{
18
ICollection<Org_SysSecMenusRecords> sMenu = org_second.getMenuByParent(parent);
19
if (sMenu.Count > 0)
20
{
21
bb.DataSource = sMenu;
22
bb.DataTextField = "ChildMenuName";
23
bb.DataValueField = "ChildMenuNo";
24
bb.DataBind();
25
}
26
}
27
28
//
绑定 checkboxlist的值
29
protected
void
BindPurviewSelected(
int
argid)
30
{
31
employee.Value = argid.ToString();
32
Org_UserRecords item = org_employees.SelectOrg_UserRecords(argid);
33
//string[] purview = item.purview.Split(new char[] { ',' });
34
string purview = item.purview;
35
foreach (DataListItem oDataListItem in Menu.Items)
36
{//注意这里. ListItem
37
foreach (ListItem oListItem in ((CheckBoxList)oDataListItem.FindControl("two_menu")).Items)
38
{
39
if (purview.Contains(oListItem.Value))
{
40
oListItem.Selected = true;
41
((CheckBox)oDataListItem.FindControl("opt")).Checked = true;
42
}
43
}
44
}
45
}
46
47
48
49
//
得到checkboxlist的值
50
protected
void
purviewEdit()
51
{
52
if (string.IsNullOrEmpty(employee.Value))
53
return;
54
55
string resultValue = string.Empty;
56
foreach (DataListItem oDataListItem in Menu.Items)
57
{
58
if (((CheckBox)oDataListItem.FindControl("opt")).Checked)
59
{
60
foreach (ListItem item in ((CheckBoxList)oDataListItem.FindControl("two_menu")).Items)
61
{
62
if (item.Selected)
63
resultValue += item.Value + ",";
64
}
65
}
66
}
67
//resultValue.TrimEnd(new char[] { ',' });
68
if (!org_employees.UpdateOrg_UserRecords("Org_UserRecords.purview", resultValue.TrimEnd(new char[]
{ ',' }), int.Parse(employee.Value)))
69
lblRurviewError.InnerHtml = "An update error about purview";
70
}
71

2

3



4

5

6

7

8

9

10

11



12

13

14

15

16

17



18

19

20



21

22

23

24

25

26

27

28

29

30



31

32

33

34

35

36



37

38



39



40

41

42

43

44

45

46

47

48

49

50

51



52

53

54

55

56

57



58

59



60

61



62

63

64

65

66

67

68



69

70

71

js 全选 [没有反选]





























































