private void BindUserGrid() { DataTable dtUser = employee.GetUserGroup(UserID); if (dtUser != null && dtUser.Rows.Count > 0) { gvUserGroup.DataSource = dtUser; gvUserGroup.DataBind(); } else { gvUserGroup.DataSource = ""; gvUserGroup.DataBind(); } upnlGroupGrid.Update(); upnlSecurityGrid.Update(); upnlPermGrid.Update(); }
public void BindUser() { try { string whereCondition = ""; MenuFrameTV.Nodes.Clear(); if (ViewState["UserInfo"] != null && ViewState["UserInfo"].ToString() != "") { whereCondition = " and EM.EmployeeName like '" + ViewState["UserInfo"].ToString() + "%'"; ViewState["UserInfo"] = ""; } else if (ViewState["UserSearch"] != null && ViewState["UserSearch"].ToString() != "") { whereCondition = " and EM.EmployeeName in (" + ViewState["UserSearch"].ToString() + ")"; ViewState["UserSearch"] = ""; } else { whereCondition = ""; } DataTable dsDetails = employee.GetUser(whereCondition); //); if (dsDetails != null && dsDetails.Rows.Count > 0) { TreeNode tvUser = new TreeNode("All Users", "Users"); MenuFrameTV.Nodes.Add(tvUser); tvUser.SelectAction = TreeNodeSelectAction.Expand; DataTable dt = dsDetails.Copy(); DataTable dtLocName = dsDetails.DefaultView.ToTable(true, "UserName"); dtLocName.DefaultView.Sort = "UserName asc"; foreach (DataRow drow in dtLocName.Rows) { dt.DefaultView.RowFilter = "UserName='******'"; DataTable dtUserName = dt.DefaultView.ToTable(); //DataTable dtG = dsDetails.Copy(); TreeNode tvUserName = new TreeNode("<table><tr><td width=200px style=\"cursor:hand;\" onclick=\"javascript:return GetUserName('" + dtUserName.Rows[0]["Name"].ToString() + "');\" >" + dtUserName.Rows[0]["Name"].ToString() + " - " + dtUserName.Rows[0]["UserName"].ToString() + " </td><td style=\"text-decoration:underline;padding-left:5px;cursor:hand;white-space: nowrap;\" onclick=\"javascript:return UserLocation('" + dtUserName.Rows[0]["LocName"].ToString() + "','" + dtUserName.Rows[0]["Name"].ToString() + "'); \"><font style=\"white-space: nowrap;\">" + dtUserName.Rows[0]["Location"].ToString() + "</font></td></tr></table>", dtUserName.Rows[0]["Name"].ToString()); tvUser.ChildNodes.Add(tvUserName); tvUserName.SelectAction = TreeNodeSelectAction.Expand; dt.DefaultView.RowFilter = "UserName='******'"; int UserID = Convert.ToInt32(dtUserName.Rows[0]["ID"].ToString()); DataTable dtGroup = employee.GetUserGroup(UserID.ToString()); if (dtGroup != null && dtGroup.Rows.Count > 0) { foreach (DataRow drow1 in dtGroup.Rows) { // TreeNode tvGroup = new TreeNode(drow1["GroupName"].ToString(), drow1["GroupName"].ToString()); TreeNode tvGroup = new TreeNode(drow1["SecurityGroupApp"].ToString(), drow1["SecurityGroupApp"].ToString()); tvUserName.ChildNodes.Add(tvGroup); tvGroup.SelectAction = TreeNodeSelectAction.Expand; } } else { TreeNode tvGroup = new TreeNode("", ""); tvUserName.ChildNodes.Add(tvGroup); tvGroup.SelectAction = TreeNodeSelectAction.Expand; } } } } catch (Exception ex) { } }