0

On my asp.net page, I have several DropDownLists. I also have a Repeater.

In the ItemDataBound event I want to get the value of these DropDownLists, to change the data in the Repeater. The SelectedValue of these DropDownLists is empty. But after the ItemDataBound, the Page_Load is executed. There I can get the value of these DropDownLists.

Is there a solution to get the value when the ItemDataBound is executed.

thanks!

Filip

Filip
  • 1,098
  • 5
  • 17
  • 34

2 Answers2

0

Can you get the drop down lists' selected values in the page PreInit event? If so, store them in view state and retrieve them from view state during the repeater's item data bound event.

If that doesn't work, try adding a selected index changed event to each drop down. When the drop downs change, set a view state variable that you can retrieve during the repeater's item data bound event. If you have values to which you are setting the drop downs during page load, such as when reading from a database, use those values to directly set the appropriate view state variables.

Zarepheth
  • 2,465
  • 2
  • 32
  • 49
0

You need to data-bind these drop-down lists in the Page.Load event.

There're a lot of web controls that get their state or other details during load life-cycle (I had these kind of problems long time ago).

NOTE: When I say "State" I'm not talking about ViewState.

And why don't you do that data-bind after the load event?

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
  • These dropdownlists are already bound in the page_load event. If I put the outside the 'if (!IsPostBack)', the selected value is resetted after a post back. And in the ItemBound event of the Repeater, the SelectedValue is still null. – Filip Jan 20 '11 at 15:14
  • the ItemDataBound is an event of the Repeater, I don't think you can chnage the "execution order"? – Filip Jan 20 '11 at 15:25
  • This event is called when you invoke DataBind() in your control. – Matías Fidemraizer Jan 20 '11 at 15:31
  • I think that's the problem, the databind's are in the page_load, but i the 'if (!IsPostBack)', so if you change the ddl, the itembound doesn't get executed well, thanks – Filip Jan 21 '11 at 06:51