.net 3.5 - DropDownList won't persist

  • Thread starter Thread starter musosdev
  • Start date Start date
M

musosdev

Hi

I have a .net 3.5 web application. It's quite complicated (nested master
pages) and all is fine, apart from my DropDownList won't persist the selected
value.

My Master Page hierarchy is as follows...

Main Master
-- Section Master
-- -- Content Page
-- -- -- ASP:Repeater
-- -- -- -- HeaderTemplate
-- -- -- -- -- DropDownList that doesn't remember!

As far as I can tell, all the Master pages, the content page, and the
repeater have "EnableViewState" set to TRUE.

The list is populated in the ASPX (not the codebehind), so that should be
fine?!

My code fires an OnSelectedIndexChanged event which grabs the value from the
DropDownList (which works fine), but then when the page reappears, the
selected ListItem is back at the default?

What's going on?! Thanks!
 
Hi

I have a .net 3.5 web application. It's quite complicated (nested master
pages) and all is fine, apart from my DropDownList won't persist the selected
value.

My Master Page hierarchy is as follows...

Main Master
-- Section Master
-- -- Content Page
-- -- -- ASP:Repeater
-- -- -- -- HeaderTemplate
-- -- -- -- -- DropDownList that doesn't remember!

As far as I can tell, all the Master pages, the content page, and the
repeater have "EnableViewState" set to TRUE.

The list is populated in the ASPX (not the codebehind), so that should be
fine?!

My code fires an OnSelectedIndexChanged event which grabs the value from the
DropDownList (which works fine), but then when the page reappears, the
selected ListItem is back at the default?

What's going on?! Thanks!

Did u set EnableViewState property of DropDownList to true?
Any code for OnSelectedIndexChanged would be much appreciated.
 
Hi

I have a .net 3.5 web application. It's quite complicated (nested master
pages) and all is fine, apart from my DropDownList won't persist the selected
value.

My Master Page hierarchy is as follows...

Main Master
-- Section Master
-- -- Content Page
-- -- -- ASP:Repeater
-- -- -- -- HeaderTemplate
-- -- -- -- -- DropDownList that doesn't remember!

As far as I can tell, all the Master pages, the content page, and the
repeater have "EnableViewState" set to TRUE.

The list is populated in the ASPX (not the codebehind), so that should be
fine?!

My code fires an OnSelectedIndexChanged event which grabs the value from the
DropDownList (which works fine), but then when the page reappears, the
selected ListItem is back at the default?

What's going on?! Thanks!

Did u set EnableViewState property of DropDownList to true?
Any code for OnSelectedIndexChanged would be much appreciated.
 
Thanks for the reply.

EnableViewState is set to True on the DropDownList, the Repeater that the
list is in, and the <asp:Content> that it all resides in.

The OnSelectedIndexChanged event is defined as follows...

protected void sortDocs(object sender, System.EventArgs e)
{
DropDownList list = (DropDownList)sender;

order_by = " ORDER BY " + list.SelectedValue.ToString();


order_by += " DESC";

Session["library_list_orderby"] = order_by;

Debug.WriteLine(order_by);
}

The function works, the order changes based on my order by clause, but the
DropDownList always shows the first item.

Thanks
 
Thanks for the reply.

EnableViewState is set to True on the DropDownList, the Repeater that the
list is in, and the <asp:Content> that it all resides in.

The OnSelectedIndexChanged event is defined as follows...

protected void sortDocs(object sender, System.EventArgs e)
{
DropDownList list = (DropDownList)sender;

order_by = " ORDER BY " + list.SelectedValue.ToString();


order_by += " DESC";

Session["library_list_orderby"] = order_by;

Debug.WriteLine(order_by);
}

The function works, the order changes based on my order by clause, but the
DropDownList always shows the first item.

Thanks
 
Thanks for the reply.

EnableViewState is set to True on the DropDownList, the Repeater that the
list is in, and the <asp:Content> that it all resides in.

The OnSelectedIndexChanged event is defined as follows...

protected void sortDocs(object sender, System.EventArgs e)
    {
        DropDownList list = (DropDownList)sender;

        order_by = " ORDER BY " + list.SelectedValue.ToString();

            order_by += " DESC";

        Session["library_list_orderby"] = order_by;

        Debug.WriteLine(order_by);
    }

The function works, the order changes based on my order by clause, but the
DropDownList always shows the first item.

Thanks



Did u set EnableViewState property of DropDownList to true?
Any code for OnSelectedIndexChanged would be much appreciated.- Hide quoted text -

- Show quoted text -

when you rebind the dropdownlist what are you setting the selected
value / index to be?
 
Thanks for the reply.

EnableViewState is set to True on the DropDownList, the Repeater that the
list is in, and the <asp:Content> that it all resides in.

The OnSelectedIndexChanged event is defined as follows...

protected void sortDocs(object sender, System.EventArgs e)
    {
        DropDownList list = (DropDownList)sender;

        order_by = " ORDER BY " + list.SelectedValue.ToString();

            order_by += " DESC";

        Session["library_list_orderby"] = order_by;

        Debug.WriteLine(order_by);
    }

The function works, the order changes based on my order by clause, but the
DropDownList always shows the first item.

Thanks



Did u set EnableViewState property of DropDownList to true?
Any code for OnSelectedIndexChanged would be much appreciated.- Hide quoted text -

- Show quoted text -

when you rebind the dropdownlist what are you setting the selected
value / index to be?
 
I'm not specifically rebinding it..

I've done a seperate test without master pages, just a DropDown in a panel
with an OnSelectedIndexChanged event, and everything else set the same.

Oddly, it works! So... what difference is the MasterPage making that causes
it to break? (the 2 nested masterpages being the only difference I can really
see...)

Thanks for the reply.

EnableViewState is set to True on the DropDownList, the Repeater that the
list is in, and the <asp:Content> that it all resides in.

The OnSelectedIndexChanged event is defined as follows...

protected void sortDocs(object sender, System.EventArgs e)
{
DropDownList list = (DropDownList)sender;

order_by = " ORDER BY " + list.SelectedValue.ToString();

order_by += " DESC";

Session["library_list_orderby"] = order_by;

Debug.WriteLine(order_by);
}

The function works, the order changes based on my order by clause, but the
DropDownList always shows the first item.

Thanks



Sreenivas said:
I have a .net 3.5 web application. It's quite complicated (nested master
pages) and all is fine, apart from my DropDownList won't persist the selected
value.
My Master Page hierarchy is as follows...
Main Master
-- Section Master
-- -- Content Page
-- -- -- ASP:Repeater
-- -- -- -- HeaderTemplate
-- -- -- -- -- DropDownList that doesn't remember!
As far as I can tell, all the Master pages, the content page, and the
repeater have "EnableViewState" set to TRUE.
The list is populated in the ASPX (not the codebehind), so that should be
fine?!
My code fires an OnSelectedIndexChanged event which grabs the value from the
DropDownList (which works fine), but then when the page reappears, the
selected ListItem is back at the default?
What's going on?! Thanks!
Did u set EnableViewState property of DropDownList to true?
Any code for OnSelectedIndexChanged would be much appreciated.- Hide quoted text -

- Show quoted text -

when you rebind the dropdownlist what are you setting the selected
value / index to be?
 
I'm not specifically rebinding it..

I've done a seperate test without master pages, just a DropDown in a panel
with an OnSelectedIndexChanged event, and everything else set the same.

Oddly, it works! So... what difference is the MasterPage making that causes
it to break? (the 2 nested masterpages being the only difference I can really
see...)

Thanks for the reply.

EnableViewState is set to True on the DropDownList, the Repeater that the
list is in, and the <asp:Content> that it all resides in.

The OnSelectedIndexChanged event is defined as follows...

protected void sortDocs(object sender, System.EventArgs e)
{
DropDownList list = (DropDownList)sender;

order_by = " ORDER BY " + list.SelectedValue.ToString();

order_by += " DESC";

Session["library_list_orderby"] = order_by;

Debug.WriteLine(order_by);
}

The function works, the order changes based on my order by clause, but the
DropDownList always shows the first item.

Thanks



Sreenivas said:
I have a .net 3.5 web application. It's quite complicated (nested master
pages) and all is fine, apart from my DropDownList won't persist the selected
value.
My Master Page hierarchy is as follows...
Main Master
-- Section Master
-- -- Content Page
-- -- -- ASP:Repeater
-- -- -- -- HeaderTemplate
-- -- -- -- -- DropDownList that doesn't remember!
As far as I can tell, all the Master pages, the content page, and the
repeater have "EnableViewState" set to TRUE.
The list is populated in the ASPX (not the codebehind), so that should be
fine?!
My code fires an OnSelectedIndexChanged event which grabs the value from the
DropDownList (which works fine), but then when the page reappears, the
selected ListItem is back at the default?
What's going on?! Thanks!
Did u set EnableViewState property of DropDownList to true?
Any code for OnSelectedIndexChanged would be much appreciated.- Hide quoted text -

- Show quoted text -

when you rebind the dropdownlist what are you setting the selected
value / index to be?
 
One possible reason is the dropdownlist' ListItem may contain duplicated
value, that is, more than one ListItem has the same ListItem.Value.
 
One possible reason is the dropdownlist' ListItem may contain duplicated
value, that is, more than one ListItem has the same ListItem.Value.
 
Back
Top