public override void DataBind() { if (_bound) { return; } _bound = true; NetworksManager nMgr = new NetworksManager(); if (NetworkId != null) { this.DataItem = nMgr.GetNetwork(NetworkId.Value); } base.DataBind(); }
public override void DataBind() { if (_bound) { return; } _bound = true; _page = this.Page as lw.Base.CustomPage; this.SelectCommand = "select Top " + Top + " * from " + TableName; string cond = ""; if (Status != null) { cond = " where Status = " + (int)Status; } else { cond = " where 1=1 "; } if (!string.IsNullOrEmpty(Condition)) { cond += string.Format(" and {0}", Condition); } if (MemberId != null && String.Compare(WebContext.Profile.dbUserName, Config.GetFromWebConfig("Admin"), true) != 0 && NetworkBound) { cond += " and NetworkId in (select NetworkId from MemberNetworks where MemberId={0}"; if (onlyPreferred != null && onlyPreferred.Value) { cond += " and Prefered=1"; } cond += ")"; cond = string.Format(cond, memberId); } if (ParentId != null) { cond += " and ParentId=" + _parentId.Value.ToString(); } if (!string.IsNullOrWhiteSpace(ParentUniqueName) && (ParentId == null)) { NetworksManager nMgr = new NetworksManager(); var parentName = nMgr.GetNetwork(ParentUniqueName); int? pId = null; if (parentName != null) { pId = parentName.NetworkId; } if (pId != null) { cond += " and ParentId = " + pId; } } if (CMSMode != null && CMSMode.Value) { string q = WebContext.Request["q"]; string netDateFrom = WebContext.Request["DateFrom"]; string netDateTo = WebContext.Request["DateTo"]; if (!string.IsNullOrWhiteSpace(q)) { cond += string.Format(" and (Name like '%{0}%' or UniqueName like '%{0}%')", StringUtils.SQLEncode(q)); } if (!string.IsNullOrWhiteSpace(netDateFrom) && !string.IsNullOrWhiteSpace(netDateTo)) { cond += string.Format(" and DateCreated between '{0}' and '{1}'", DateTime.Parse(netDateFrom), DateTime.Parse(netDateTo)); } else if (!string.IsNullOrWhiteSpace(netDateFrom)) { cond += string.Format(" and DateCreated >= '{0}'", DateTime.Parse(netDateFrom)); } else if (!string.IsNullOrWhiteSpace(netDateTo)) { cond += string.Format(" and DateCreated <= '{0}'", DateTime.Parse(netDateTo)); } } if (!string.IsNullOrWhiteSpace(OrderBy)) { cond += " Order By " + OrderBy; } this.SelectCommand += cond; base.DataBind(); }