[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

DropDown with no viewstate and Unique Name

(Douglas Tarr)

1/21/2003 10:09:00 PM

I am using an <asp:dropdown id="MyDropDown"> control, with viewstate
disabled on the page. In the Page_Load event, I have a function that
populates the dropdown from the db.

The form variable name is unique (from INamingContainer) because this
particular webcontrol is wrapped in a UserControl. So the name ends
up looking like: "MyUserControl:MyDropDown" in the form variable
list. Since I have no control over that name, I'm very wary of
referencing the form variable as
Request.Form["MyUserControl:MyDropDown"], because this will change,
if, for instance, I add a second instance of MyUserControl to my
webform (since the names must be unique.

So how do I get the selectedIndex of MyDropDown without referencing
the unique name of the form variable? It always comes up as -1.

Thx,
Doug
1 Answer

Ken Cox [MS MVP]

1/16/2003 12:10:00 AM

0

Just wondering if it is possible to use the Page.FindControl method to get a
handle on MyDropDown?

Ken

"Douglas Tarr" <tarr11@yahoo.com> wrote in message
news:ca4ab2a0.0301151049.208e9f60@posting.google.com...
I am using an <asp:dropdown id="MyDropDown"> control, with viewstate
disabled on the page. In the Page_Load event, I have a function that
populates the dropdown from the db.

The form variable name is unique (from INamingContainer) because this
particular webcontrol is wrapped in a UserControl. So the name ends
up looking like: "MyUserControl:MyDropDown" in the form variable
list. Since I have no control over that name, I'm very wary of
referencing the form variable as
Request.Form["MyUserControl:MyDropDown"], because this will change,
if, for instance, I add a second instance of MyUserControl to my
webform (since the names must be unique.

So how do I get the selectedIndex of MyDropDown without referencing
the unique name of the form variable? It always comes up as -1.

Thx,
Doug