.NET ------ 树形菜单,点击单选按钮触发相应事件
主要就是包括两个,树形菜单和单选按钮
先获取菜单的所有值,在实现点击获取相应数据
<table width ="100%" cellpadding="0" cellspacing="0" border="0" class="ttable_border_none"> <tr><td align ="left"><asp:HiddenField ID="HidTreeWhere" runat="server" Value=""/><img src="../../qdAdmin/qdimages/files/check01/00.png" /> 采购单</td></tr> <asp:Repeater ID ="RepeaterTree" runat="server" OnItemDataBound="RepeaterTree_ItemDataBound"> <ItemTemplate> <tr bgcolor ="#FFFFFF" onMouseOver="this.bgColor='#EEEEEE'" onMouseOut="this.bgColor='#FFFFFF'"> <td align ="left" style="white-space: nowrap"> <asp:HiddenField ID="HidGuid" runat="server" Value='<%# DataBinder.Eval(Container.DataItem,"CaiGouDanGuid") %>' /><img src="../../qdAdmin/qdimages/files/check01/10.png" /> <asp:CheckBox ID="chkMark" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"CaiGouDanMark") %>' AutoPostBack="true" OnCheckedChanged="chkMark_CheckedChanged" /> <a href="javascript:return false;" title="详细" onclick="javascript:WebDialogLoad('<%# DataBinder.Eval(Container.DataItem,"CaiGouDanMark") %>',1000,600, 'CaiGou_List_win.aspx?pwidth=980&pheight=480&id=<%# DataBinder.Eval(Container.DataItem,"CaiGouDanGuid") %>&edit=show')" ><img src="../../qdadmin/qdimages/Select.png" border="0" title="详细"></a> </td> </tr> </ItemTemplate> </asp:Repeater> </table>
获取相应值,借助 Repeater 进行遍历,前面和 <%# DataBinder.Eval(Container.DataItem,"数据库字段名") %> 一块连用
private void TreeLoad() { #region Tree List<ITEM.Model.Mis4.BCaiGouDan> mTreeList = _bllCaiGouDan.GetListSelBCaiGouDan3("CaiGouDanMark,CaiGouDanGuid", base.EnterpriseGuid, GetSearchSql_Tree() + " and DeptCode like '"+_XUserLogin.UserLoginOrganizationCode+"%' order by CaiGouDanMark"); this.RepeaterTree.DataSource = mTreeList; this.RepeaterTree.DataBind(); #endregion } protected void RepeaterTree_ItemDataBound(object sender, RepeaterItemEventArgs e) { string s = HidTreeWhere.Value; if (s == string.Empty) return; CheckBox chk = (CheckBox)e.Item.FindControl("chkMark"); HiddenField hid = (HiddenField)e.Item.FindControl("HidGuid"); if (s.IndexOf(hid.Value) >= 0) { chk.Checked = true; } else { chk.Checked = false; } }
点击单选获取相应的值
protected void chkMark_CheckedChanged(object sender, EventArgs e) { HidTreeWhere.Value = string.Empty; string s = string.Empty; for (int i = 0; i <= RepeaterTree.Items.Count - 1; i++) { CheckBox chk = (CheckBox)RepeaterTree.Items[i].FindControl("chkMark"); HiddenField hid = (HiddenField)RepeaterTree.Items[i].FindControl("HidGuid"); if (chk.Checked == true) { string sign = s == string.Empty ? "" : ","; s += sign + hid.Value; } } s = "'" + s + "'"; s = s.Replace(",", "','"); HidTreeWhere.Value = s; HtmlTableLoad(); }