Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Drop down list does not see the selected item!

Reply
Thread Tools

Drop down list does not see the selected item!

 
 
=?Utf-8?B?TWVyZGFhZA==?=
Guest
Posts: n/a
 
      10-20-2004
My drop down list is populated from a static array in my codebehind (c#)
code.
I set the selected index based on some known values(from DB), when the
screen shows up, dropdown list shows that the the first items is selected and
not the one assigned.

Please note that if I hardcode the dropdown items inside the .aspx file,
everything works fine.

Please point me to examples(infopath examples somehow don't show up for me!).

Thanks
 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      10-20-2004
It'd be helpful if you showed us what you have so far, such as how the
dropdownlist is populated (are you binding, or looping through your array
and adding items), and how the selected item is being set.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


"Merdaad" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> My drop down list is populated from a static array in my codebehind (c#)
> code.
> I set the selected index based on some known values(from DB), when the
> screen shows up, dropdown list shows that the the first items is selected

and
> not the one assigned.
>
> Please note that if I hardcode the dropdown items inside the .aspx file,
> everything works fine.
>
> Please point me to examples(infopath examples somehow don't show up for

me!).
>
> Thanks



 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWVyZGFhZA==?=
Guest
Posts: n/a
 
      10-20-2004
Thanks for replying.

Here is my code:
String[] usStates;
usStates = (String[]) Application.Get("states");
bStDDList.DataSource = usStates;
bStDDList.DataBind();
......
...

bStDDList.SelectedIndex = Convert.ToInt16(DataBinder.Eval(custDataSet,
"Tables[getCustomerData].DefaultView.[0].bState",""));

/*debugger shows bStDDList.SelectedIndex to be the correct index*/



"Karl Seguin" wrote:

> It'd be helpful if you showed us what you have so far, such as how the
> dropdownlist is populated (are you binding, or looping through your array
> and adding items), and how the selected item is being set.
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "Merdaad" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
> > My drop down list is populated from a static array in my codebehind (c#)
> > code.
> > I set the selected index based on some known values(from DB), when the
> > screen shows up, dropdown list shows that the the first items is selected

> and
> > not the one assigned.
> >
> > Please note that if I hardcode the dropdown items inside the .aspx file,
> > everything works fine.
> >
> > Please point me to examples(infopath examples somehow don't show up for

> me!).
> >
> > Thanks

>
>
>

 
Reply With Quote
 
Karl Seguin
Guest
Posts: n/a
 
      10-20-2004
Typically, you set the selectedindex via:

bstDDList.SelectedIndex =
bstDDList.Items.IndexOf(bstDDList.Items.FindByValu e(some string value))

I imagine bState is the actual state code, which probably doesn't match up
to the array index of your list item...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


"Merdaad" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks for replying.
>
> Here is my code:
> String[] usStates;
> usStates = (String[]) Application.Get("states");
> bStDDList.DataSource = usStates;
> bStDDList.DataBind();
> .....
> ..
>
> bStDDList.SelectedIndex = Convert.ToInt16(DataBinder.Eval(custDataSet,
> "Tables[getCustomerData].DefaultView.[0].bState",""));
>
> /*debugger shows bStDDList.SelectedIndex to be the correct index*/
>
>
>
> "Karl Seguin" wrote:
>
> > It'd be helpful if you showed us what you have so far, such as how the
> > dropdownlist is populated (are you binding, or looping through your

array
> > and adding items), and how the selected item is being set.
> >
> > Karl
> >
> > --
> > MY ASP.Net tutorials
> > http://www.openmymind.net/
> >
> >
> > "Merdaad" <(E-Mail Removed)> wrote in message
> > news(E-Mail Removed)...
> > > My drop down list is populated from a static array in my codebehind

(c#)
> > > code.
> > > I set the selected index based on some known values(from DB), when the
> > > screen shows up, dropdown list shows that the the first items is

selected
> > and
> > > not the one assigned.
> > >
> > > Please note that if I hardcode the dropdown items inside the .aspx

file,
> > > everything works fine.
> > >
> > > Please point me to examples(infopath examples somehow don't show up

for
> > me!).
> > >
> > > Thanks

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?TWVyZGFhZA==?=
Guest
Posts: n/a
 
      10-20-2004
I think the result is the same either way.

tw. How do you add to a drop down list after it's bound to its datasource.
I have tried ....items.insert and ..items.add neither one works. I can't
even modify the items that are already there.

Thanks

"Karl Seguin" wrote:

> Typically, you set the selectedindex via:
>
> bstDDList.SelectedIndex =
> bstDDList.Items.IndexOf(bstDDList.Items.FindByValu e(some string value))
>
> I imagine bState is the actual state code, which probably doesn't match up
> to the array index of your list item...
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "Merdaad" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Thanks for replying.
> >
> > Here is my code:
> > String[] usStates;
> > usStates = (String[]) Application.Get("states");
> > bStDDList.DataSource = usStates;
> > bStDDList.DataBind();
> > .....
> > ..
> >
> > bStDDList.SelectedIndex = Convert.ToInt16(DataBinder.Eval(custDataSet,
> > "Tables[getCustomerData].DefaultView.[0].bState",""));
> >
> > /*debugger shows bStDDList.SelectedIndex to be the correct index*/
> >
> >
> >
> > "Karl Seguin" wrote:
> >
> > > It'd be helpful if you showed us what you have so far, such as how the
> > > dropdownlist is populated (are you binding, or looping through your

> array
> > > and adding items), and how the selected item is being set.
> > >
> > > Karl
> > >
> > > --
> > > MY ASP.Net tutorials
> > > http://www.openmymind.net/
> > >
> > >
> > > "Merdaad" <(E-Mail Removed)> wrote in message
> > > news(E-Mail Removed)...
> > > > My drop down list is populated from a static array in my codebehind

> (c#)
> > > > code.
> > > > I set the selected index based on some known values(from DB), when the
> > > > screen shows up, dropdown list shows that the the first items is

> selected
> > > and
> > > > not the one assigned.
> > > >
> > > > Please note that if I hardcode the dropdown items inside the .aspx

> file,
> > > > everything works fine.
> > > >
> > > > Please point me to examples(infopath examples somehow don't show up

> for
> > > me!).
> > > >
> > > > Thanks
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
1st Drop-down selection determins selected value in all drop-downs In ASP.Net Wizard jaysch ASP .Net 0 04-30-2011 02:19 PM
Enable second drop down after first drop down is selected teser3@hotmail.com Javascript 0 01-28-2009 12:59 AM
retrive preselected value in second drop down list from the first drop down list weiwei ASP .Net 0 01-05-2007 07:29 PM
Auto Drop down a Drop Down List xxbmichae1@supergambler.com Javascript 5 11-23-2005 01:35 AM
Web User Control Drop Down List does not show selected item stephg ASP .Net Building Controls 3 10-30-2005 01:00 PM



Advertisments