DropDownListBox and footer and datagrid

K

kgs

I dynamically added a DropDownListBox to a footer of
datagrid on itemcreated event.
In which event in postback can i access the selected item.

Interesting thing i noted that even though i create it,
every time on postback of the page the selected item is
preserved.

thanks!!!
 
T

Teemu Keiski

Hi,

you could dynamically wire an event handler for the DDL (when it is created
in ItemCreated) to handle it's SelectedIndexChanged. The DDL just needs to
have AutoPostBack="True" specified if you want postback to happen when
selection changes. Then you wouldn't need to "guess" what's the event to
check it, you just handle DDL's very own SelectedIndexChanged event that is
raised when change in selection is detected. Otherwise, if it is another
control that causes the postback (say ButtonColumn or a Button in the same
DatagridItem), you would search the DDL from current DataGridItem's Controls
collection and just check its selected value.

Yes, it keeps state as postback data for the DDL is loaded (once before
Page_Load and second try after Page_Load) and the selected item is
"restored" that way. Dynamically created controls can keep their state
equivally as static controls as long as they follow certain rules (and it
does here, because DataGrid tahes care of creating the Controls)
 
K

kgs

Thank You very much.
-----Original Message-----
Hi,

you could dynamically wire an event handler for the DDL (when it is created
in ItemCreated) to handle it's SelectedIndexChanged. The DDL just needs to
have AutoPostBack="True" specified if you want postback to happen when
selection changes. Then you wouldn't need to "guess" what's the event to
check it, you just handle DDL's very own
SelectedIndexChanged event that is
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top