GridDropDownColumn - is it possible to set datasource instead of datasourceID?
In the sample I see
DataSourceID="SqlDataSource4"
But I'd like to bind the column in the code behind.
Our situation is a little unique. We have developed a framework which allows us to create dynamic grids that load based on the customer's needs and everything is generated on the pageinit and then loaded into a placeholder.
Right now we have to bind our dropdowns in the itemdatabound, which works but we could easily build it all in if we could set the datasource rather than just a datasourceid (but maybe there's a solution?)
Here's our method that creates the dropdown column (method is called in a foreach loop that loops through each column that needs to be generated, the code below is just one method of many that generates different column controls):
/// <summary>/// Generates a dropdown field/// </summary>/// <param name="grid">radgrid where column is added</param>/// <param name="column">column properties</param>private static void CreateDropdownCol(RadGrid grid, SCSowFormColumn column){ List<TableStructure> testList = new List<TableStructure>(); GridDropDownColumn col = new GridDropDownColumn(); col.UniqueName = column.SCSFC_Name; col.DataField = column.SCSFC_Name; col.HeaderText = column.SCSFC_ColumnHeaders; col.FilterControlWidth = Unit.Pixel(column.SCSFC_Width - 35); col.HeaderStyle.Width = Unit.Pixel(column.SCSFC_Width); col.AllowFiltering = column.SCSFC_AllowFilter; if (column.SCSFC_Required) { col.ColumnValidationSettings.EnableRequiredFieldValidation = column.SCSFC_Required; col.ColumnValidationSettings.RequiredFieldValidator.InitialValue = "(Select...)";//initial value is the text that is displayed col.ColumnValidationSettings.RequiredFieldValidator.ErrorMessage = " *Required"; col.ColumnValidationSettings.RequiredFieldValidator.Display = ValidatorDisplay.Dynamic; col.ColumnValidationSettings.RequiredFieldValidator.CssClass = "IPROD_ERROR_MESSAGE"; } //checkto see if the column should be shown in itemview mode col.Display = !column.SCSFC_DoNotDisplay; //check to see if the column should be shown in edit mode col.ReadOnly = column.SCSFC_ReadOnly; //WOULD BE NICE IF WE COULD DO:
//List<TestList> list = new List<TestList>();
//col.DataSource = list;
//col.ListTextField = "Name";
//col.ListValueField = "ID";
//multi column single line edit forms col.EditFormColumnIndex = column.SCSFC_ColumnIndex; grid.MasterTableView.Columns.Add(col);}
Anyone have any ideas?
