public void EnsureTextByValue(Object value) { if (!String.IsNullOrEmpty(Convert.ToString(value))) { TableDataSourceView _data = (TableDataSourceView)GetData(); TableDataSourceView tableDataSourceView = new TableDataSourceView( null, _data.ShowHistoricalData, _data.LoadAllHistoricalData, _data.EndDateField, _data.StartDateField, _data.HistolicalPoint, _data.CustomConditions, _data.SelectMethod, _data.TypeName, _data.GetSelectParameters(), _data.GetFilterParameters(), _data.FilterExpression, _data.SetFilterByCustomConditions); if (_data.HistoricalCountKeys == 1) { tableDataSourceView.HistoricalKey = _data.HistoricalKey; tableDataSourceView.HistoricalSelectMethod = _data.HistoricalSelectMethod; tableDataSourceView.HistoricalCountKeys = 1; tableDataSourceView.HistoricalValues[0] = value; } QueryCondition queryCondition = new QueryCondition(DataValueField, ColumnFilterType.Equal, value, null); tableDataSourceView.CustomConditions.Add(queryCondition); DataView dataView; try { DataSourceSelectArguments arguments = new DataSourceSelectArguments(); dataView = (DataView)tableDataSourceView.Select(true, arguments, new DataSourceSelectExtArguments(1)); } finally { tableDataSourceView.CustomConditions.Remove(queryCondition); } //выполнение запроса должно помещать 1 запись в таблицу if (dataView.Table.Rows.Count == 1) { Text = dataView.Table.Rows[0][DataTextField].ToString(); } else if (dataView.Count == 1) { Text = dataView[0][DataTextField].ToString(); } else { Text = ""; } } else { Text = ""; } textBox.Text = Text; }
private void FillProps() { TableDataSourceView _data = (TableDataSourceView)GetData(); if (!DesignMode && _data != null && !String.IsNullOrEmpty(DataTextField) && !String.IsNullOrEmpty(DataValueField)) { Hashtable props = new Hashtable(); props["ShowHistoricalData"] = _data.ShowHistoricalData; props["LoadAllHistoricalData"] = _data.LoadAllHistoricalData; props["EndDateField"] = _data.EndDateField; props["StartDateField"] = _data.StartDateField; props["HistolicalPoint"] = _data.HistolicalPoint; props["QueryConditionsList"] = _data.CustomConditions; props["FilterParameters"] = _data.GetFilterParameters(); props["SelectMethod"] = _data.SelectMethod; props["TypeName"] = _data.TypeName; props["SelectParameters"] = _data.GetSelectParameters(); props["DataTextField"] = DataTextField; props["DataCodeField"] = DataCodeField; props["DataValueField"] = DataValueField; props["DataDisableRowField"] = DataDisableRowField; props["ConditionValue"] = ConditionValue; props["FilterExpression"] = _data.FilterExpression; props["SetFilterByCustomConditions"] = _data.SetFilterByCustomConditions; Page.Session[WebMethodSessionKey] = props; } }