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

[Solved] Dynamically created columns

3 Answers 136 Views
Grid
This is a migrated thread and some comments may be shown as answers.
melkorman
Top achievements
Rank 1
melkorman asked on 19 Feb 2010, 01:30 PM
Hi,

I need to dynamically create my columns in a radgrid, because I do not know how many columns I need to display.

The data to be displayed is fetched in the event handler of a button. When I receive that data I know how many columns to create. Problem is, this event handler is run after Page_Load, which as I understand it is the place where you have to create your grid columns for them to show up.

The result at the moment is that the grid is not shown until I click the button again, at which point the data is available at Page_Load and the columns is created accordingly. How can I solve this problem? I obviously want the result to be displayed after only one post back!

Best regards

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Feb 2010, 04:26 AM
Hi,

You need to store the number of columns created in a View State in the button click and then recreate them in the Page Load on IsPostBack true condition.This way you will be able to add the same number of columns on a postback .

Hope this helps.

Thanks,
Princy
0
melkorman
Top achievements
Rank 1
answered on 24 Feb 2010, 03:32 PM
Thank you for your reply.

If I understand you correctly, you are talking about how to recreate the columns after a post back. My problem is creating them the first time without having to perform a second post back.

Please read my first post once more. I hope my explanation there of the problem is accurate enough, otherwise I will try to make a new one!

Cheers!
0
R N
Top achievements
Rank 1
answered on 24 Feb 2010, 06:03 PM
Tags
Grid
Asked by
melkorman
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
melkorman
Top achievements
Rank 1
R N
Top achievements
Rank 1
Share this question
or