By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,017 Members | 997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,017 IT Pros & Developers. It's quick & easy.

DropDownListBox and footer and datagrid

P: n/a
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!!!
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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)

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"kgs" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
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!!!

Nov 18 '05 #2

P: n/a
kgs
Thank You very much.
-----Original Message-----
Hi,

you could dynamically wire an event handler for the DDL (when it is createdin ItemCreated) to handle it's SelectedIndexChanged. The DDL just needs tohave AutoPostBack="True" specified if you want postback to happen whenselection changes. Then you wouldn't need to "guess" what's the event tocheck it, you just handle DDL's very own SelectedIndexChanged event that israised when change in selection is detected. Otherwise, if it is anothercontrol that causes the postback (say ButtonColumn or a Button in the sameDatagridItem), you would search the DDL from current DataGridItem's Controlscollection and just check its selected value.

Yes, it keeps state as postback data for the DDL is loaded (once beforePage_Load and second try after Page_Load) and the selected item is"restored" that way. Dynamically created controls can keep their stateequivally as static controls as long as they follow certain rules (and itdoes here, because DataGrid tahes care of creating the Controls)
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"kgs" <an*******@discussions.microsoft.com> wrote in messagenews:01****************************@phx.gbl...
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!!!

.

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.