This is a migrated thread and some comments may be shown as answers.

Change radGrid column as dropdown at runtime

1 Answer 142 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 07 Aug 2011, 09:29 PM
Hi,

I 'm using RadGrid to display data and allow users to change the data.  The constraint I have is that the number of columns to be displayed varies depending on the user's search criteria.  Therefore, I don't predefine the grid columns at design time, rather, I set the grid to AutoGenerateColumn="true" and the columns are generated automatically based on a datatable returned by a stored procedure.

I'm also using EditMode="InPlace" to allow users to edit any cell(s) in the grid in place (some columns are set to readyOnly to disable editing).  When user clicks an UpdateAll button, the code captures the changed values from the grid cells and updates the database.

That all works very well.

Now, I would like to do the following:

1. Display one of the columns as a dropdown list, e.g. country code (so users can change the selection).  I don't know how to, at run time, change an auto-generated column to a dropdown and correctly bind the dropdown to the right datasource.  I presume this is all doable?  Can any one point me to the right direction, or sample codes?  Again, the key is: change an auto-genearted column to dropdown at run time. 

Thanks in advance.

Barry

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 11 Aug 2011, 11:48 AM
Hi Barry,

When using autogenerated columns, they can vary only based on the datatype of the field that they are bound to. From there on, you cannot control the type of column generated. In this situation you could hide the autogenerated column for this field and declare a GridDropDownColumn explicitly.

Additionally, if you are at an early stage of creating the grid, you can consider the approach for dynamic column creation in Page_Init:
Changing the Grid Structure Dynamically on Postback

Greetings,
Tsvetina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Barry
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or