Access To A Component.SelectedItem in Page_Init

A

awalker1

Hi all,

I have a datagrid and a drop down list on my page.

The DataGrid is created dynamically at runtime to contain columns based on
the item that the user has selected from the drop down list. Some of the
columns need to be a ButtonColumn so that the user can click on them to be
taken to another page. This "click" is handled by the ItemCommand" event of
the datagrid.

In order to correctly associate the ItemCommand event to the dynamically
created button columns, I have to setup the grid in the Page_Init event. If
I don't do it here then the event never gets fired (and this is well
documented on the net).

My problem is that in order to set the grid up correctly, I need to access
the SelectedItem of the combo box in the Page_Init event, BUT, the combo box
hasn't been initialised at this point. I can access the combo box in the
Page_Load event but this is too late to setup the grid. I'm in a catch 22.

So, how can I access the SelectedItem of my combo box in the Page_Init
event? If I can't access it directly, can I access it through another
route?

Help please?

Andy
 
A

Andy Walker

Apparently not no. I googled for this error and I thought that I had read
lots of posts where the problem was solved by creating the columns in the
Page_Init, and this seemed to work if I hard coded the values. However, my
requirement was to use a value from a user control.

I have just re-googled and I can't find a single post stating that. Are you
suggesting that this isn't the case, or are you just asking the question?

BUT, despite that, using hard-coded values if I set my columns up in the
Page_Init then the event never fires, if I set them up in the Page_Load then
the event fires.

Thanks for the link anyway.

Andy
 
A

awalker1

Have my related posts for this item been deleted for some reason?

I definately had some responses and I replied to them but the now seem to
have disappeared.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top