DropDownListBox and footer and datagrid

  • Thread starter Thread starter kgs
  • Start date Start date
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!!!
 
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)
 
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
 
Back
Top