FrancineTaylor
asked on
How to get the selected item from a dropdown box bound to an array of custom objects
I create an array of custom objects and bind it to a dropdown box.
SQLObject[] boxes = new SQLObject[] {
new SQLObject(eRecordType.EMPL OYEE, "SELECT TOP 15 * FROM dbo.Employee"),
new SQLObject(eRecordType.LOGG ER, "SELECT TOP 15 * FROM dbo.Logger")};
ddBindArray.DataSource = boxes;
ddBindArray.DataBind();
Then in the selected index changed event, I want to get the item selected:
protected void ddBindArray_SelectedIndexC hanged(obj ect sender, EventArgs e) {
I tried getting the selected item and casting it...
SQLObject current = (SQLObject)ddBindArray.Sel ectedItem;
I also tried getting the indexed item
SQLObject current = (SQLObject)ddBindArray.Ite ms[ddBindA rray.Selec tedIndex];
..but both times I got this error at compile time:
Cannot convert type 'System.Web.UI.WebControls .ListItem' to 'SQLObject'
How can I get the object selected without having to store the original array and refer back to it?
SQLObject[] boxes = new SQLObject[] {
new SQLObject(eRecordType.EMPL
new SQLObject(eRecordType.LOGG
ddBindArray.DataSource = boxes;
ddBindArray.DataBind();
Then in the selected index changed event, I want to get the item selected:
protected void ddBindArray_SelectedIndexC
I tried getting the selected item and casting it...
SQLObject current = (SQLObject)ddBindArray.Sel
I also tried getting the indexed item
SQLObject current = (SQLObject)ddBindArray.Ite
..but both times I got this error at compile time:
Cannot convert type 'System.Web.UI.WebControls
How can I get the object selected without having to store the original array and refer back to it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
What I was actually looking for is a way to bind the array (or collection) of objects to a control such that I wouldn't have to store and retrieve (probably with Session) the original collection.
When I bind an array to a client control, does that array exist client-side, or does the control only contain the strings which it displays?