public object GetProductDictionaryText(Guid entityID, DictionaryTree entity) { string sql = "select [{0}] from {1} where [{2}] = '{3}'"; sql = string.Format(sql, entity.Dictionary.IdentifierField, entity.Dictionary.TableName, entity.PK, entityID); using (CommonDataProvider provider = new CommonDataProvider()) { return provider.ExecuteScalar(sql); } }
protected void SelectorGrid_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.DataItem != null) { if (e.Row.RowState == DataControlRowState.Alternate) e.Row.CssClass += " row2"; //HyperLink link = e.Row.Cells[0].FindControl("СhooseButton") as HyperLink; HyperLink link = e.Row.Cells[0].Controls[0] as HyperLink; link.NavigateUrl = "javascript:void(0);"; using (DictionaryProvider provider = new DictionaryProvider()) { if (tree == null) tree = provider.GetDictionaryTreeNode(this.DictionaryTreeID); Guid id = new Guid(DataBinder.Eval(e.Row.DataItem, /*this.ValueField*/"ID").ToString()); string text = provider.GetProductDictionaryText(id, tree).ToString(); string function; if (MultiMode) { function = String.Format("fnSelectRow('{0}','{1}');return false;", id, text); e.Row.CssClass += " " + id.ToString(); var pair = MultiSelection.Value.Split(';').Where(i => !String.IsNullOrEmpty(i)); ; var idsList = pair.Select(i => new Guid (i.Split(':').First())); if (idsList.Contains(id)) e.Row.CssClass += " RowSelected"; } else { function = String.Format("self.parent.setSelectedValue('{0}','{1}','{2}','{3}');self.parent.tb_remove();return false;", this.HiddenControlID, id, this.TextControlID, text); } //string function = String.Format("self.parent.setSelectedValue('{0}','{1}','{2}','{3}');self.parent.tb_remove();return false;", this.HiddenControlID, DataBinder.Eval(e.Row.DataItem, /*this.ValueField*/"ID"), this.TextControlID, DataBinder.Eval(e.Row.DataItem, this.TextField)); link.Attributes.Add("onclick", function); } e.Row.Attributes["onmouseover"] = "highLightRow(this)"; e.Row.Attributes["onmouseout"] = "unHighLightRow(this)"; } } }