Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Combo ListBox selected Index problem

Reply
Thread Tools

Combo ListBox selected Index problem

 
 
Jacques
Guest
Posts: n/a
 
      07-14-2004
Hi,

I've got a user control with a couple of textboxes and one combo listbox.

When the save button is clicked the textbox values are passed back no
problem, but the combo listbox selectedIndex is not set even though it was
selected.

Any ideas?

Thanks
Jacques


 
Reply With Quote
 
 
 
 
Dale
Guest
Posts: n/a
 
      07-15-2004
Search your code for where you populate the listbox. Is it happening before
you test it on postback? Generally these issues are caused by
re-initializing the control before testing the value on postback.

Try stepping through your code in debug mode and you should see that
happening.

To fix it, make sure you either initialize your control only if
(!IsPostBack) or if you must re-initialize it on each load, make sure you
retreive the value first.

Dale

"Jacques" <(E-Mail Removed)> wrote in message
news:cd315g$515$(E-Mail Removed)...
> Hi,
>
> I've got a user control with a couple of textboxes and one combo listbox.
>
> When the save button is clicked the textbox values are passed back no
> problem, but the combo listbox selectedIndex is not set even though it was
> selected.
>
> Any ideas?
>
> Thanks
> Jacques
>
>



 
Reply With Quote
 
 
 
 
Jacques
Guest
Posts: n/a
 
      07-15-2004
Thanks for the reply Dale.

Unfortunately postback will occur no matter what, because this is a
composite control.

But when the user clicks the save button, I manage to avoid the reload of
the values.

Is there anything else you can think of?

Thanks
Jacques

"Dale" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Search your code for where you populate the listbox. Is it happening

before
> you test it on postback? Generally these issues are caused by
> re-initializing the control before testing the value on postback.
>
> Try stepping through your code in debug mode and you should see that
> happening.
>
> To fix it, make sure you either initialize your control only if
> (!IsPostBack) or if you must re-initialize it on each load, make sure you
> retreive the value first.
>
> Dale
>
> "Jacques" <(E-Mail Removed)> wrote in message
> news:cd315g$515$(E-Mail Removed)...
> > Hi,
> >
> > I've got a user control with a couple of textboxes and one combo

listbox.
> >
> > When the save button is clicked the textbox values are passed back no
> > problem, but the combo listbox selectedIndex is not set even though it

was
> > selected.
> >
> > Any ideas?
> >
> > Thanks
> > Jacques
> >
> >

>
>



 
Reply With Quote
 
Dale
Guest
Posts: n/a
 
      07-15-2004
I'm not sure what you mean by postback will occur no matter what; my
suggestion was based on that assumption already.

There is on scenario I have run across where IsPostback will give you
potentially unexpected results. I have had a page before where, when the
user hits the enter key without having a control focused that causes
postback. In this case IsPostback can return false, even though the
customer thinks he has submitted the form and the form does reload.

In the case I am referring to, the customer would enter a number into an
HTML textbox and hit enter without clicking the submit button. In the
codebehind I tested IsPostback and in that case IsPostback was false, giving
undesired results. I ended up having to test the textbox value as well; if
it wasn't empty then I treated the load event as a postback event. Perhaps
this is what is going on in your case. Just a thought.

The previous suggestion and this one are the only two things I have seen
cause values to be lost. Perhaps you could post some of your code.

Dale


"Jacques" <(E-Mail Removed)> wrote in message
news:cd5dcc$ca1$(E-Mail Removed)...
> Thanks for the reply Dale.
>
> Unfortunately postback will occur no matter what, because this is a
> composite control.
>
> But when the user clicks the save button, I manage to avoid the reload of
> the values.
>
> Is there anything else you can think of?
>
> Thanks
> Jacques
>
> "Dale" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Search your code for where you populate the listbox. Is it happening

> before
> > you test it on postback? Generally these issues are caused by
> > re-initializing the control before testing the value on postback.
> >
> > Try stepping through your code in debug mode and you should see that
> > happening.
> >
> > To fix it, make sure you either initialize your control only if
> > (!IsPostBack) or if you must re-initialize it on each load, make sure

you
> > retreive the value first.
> >
> > Dale
> >
> > "Jacques" <(E-Mail Removed)> wrote in message
> > news:cd315g$515$(E-Mail Removed)...
> > > Hi,
> > >
> > > I've got a user control with a couple of textboxes and one combo

> listbox.
> > >
> > > When the save button is clicked the textbox values are passed back no
> > > problem, but the combo listbox selectedIndex is not set even though it

> was
> > > selected.
> > >
> > > Any ideas?
> > >
> > > Thanks
> > > Jacques
> > >
> > >

> >
> >

>
>



 
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
need help to fill textboxes from a selected item in datagrid-selected index changed. mldardy ASP .Net 0 09-28-2010 02:59 PM
sorting index-15, index-9, index-110 "the human way"? Tomasz Chmielewski Perl Misc 4 03-04-2008 05:01 PM
Listbox move multiple selected items to second listbox K B ASP .Net 2 01-08-2007 11:16 AM
Listbox NOT retrieving Selected Index Chris Thunell ASP .Net 3 07-28-2004 06:26 PM
how to know all of index of selected item on web listbox control haiwen ASP .Net Web Controls 3 07-14-2003 01:44 PM



Advertisments