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

Programmatic Creation of Grid

1 Answer 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JK
Top achievements
Rank 1
JK asked on 17 Mar 2009, 03:20 PM
I have a page that contains a dropdownlistbox(autopostback=true) , a button and a radgrid. Depending on the selected index of the dropdownlistbox, when the user clicks on the button, I would like to bind the grid to the appropriate datasource. Since the columns displayed are different for each item selected in the dropdownlistbox, I am creating the grid programmatically in a function called "PopulateGrid". This function is being called in the page_preinit event as per the documentation.

However, I find that I have to click the button twice to retrieve the correct selected item in the dropdown to bind the grid to the correct dataset. This is because the grid is being bound in page preinit. The dropdownlistbox selected index changed event and button click event are fired after the page preinit. The 2nd time the button is clicked is when the correct selected index is retrieved.

Any workarounds to calling the PopulateGrid in the page_preinit event?

Thanks.

JK

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 19 Mar 2009, 06:11 PM
Hi JK,

You can use the Page_Load event and create the grid in it as shown in the following online example: here. The new combo box selected value should be loaded by the time the Page_Load event is called and you can get hold of it in the handler for the latter.

Best Regards,
Tsvetoslav
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
JK
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or