Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Combobox Id

Reply
Thread Tools

Combobox Id

 
 
Big E
Guest
Posts: n/a
 
      06-11-2004
I'm using VB in ASP.Net with SQL Server 2000.

I have a States Combobox that lists the State. The State has a StateId in
table states. When I do updates to various tables from the form I would like
to update the StateId not the StateName. I've looked at the datamember and
datavalue stuff but don't understand it.

Can anyone point me at a sample or some code they've used.

Thanks.

Big E



 
Reply With Quote
 
 
 
 
Curt_C [MVP]
Guest
Posts: n/a
 
      06-11-2004
Combo box or DropDownList?
should be
this.DropDownList1.SelectedItem.Value
or
this.DropDownList1.SelectedItem.Text

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com


"Big E" <(E-Mail Removed)> wrote in message
news:eQHGLW%(E-Mail Removed)...
> I'm using VB in ASP.Net with SQL Server 2000.
>
> I have a States Combobox that lists the State. The State has a StateId in
> table states. When I do updates to various tables from the form I would

like
> to update the StateId not the StateName. I've looked at the datamember and
> datavalue stuff but don't understand it.
>
> Can anyone point me at a sample or some code they've used.
>
> Thanks.
>
> Big E
>
>
>



 
Reply With Quote
 
 
 
 
Big E
Guest
Posts: n/a
 
      06-11-2004
Your the best. Curt is the champ. It works.



"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:uTFS1m%(E-Mail Removed)...
> Combo box or DropDownList?
> should be
> this.DropDownList1.SelectedItem.Value
> or
> this.DropDownList1.SelectedItem.Text
>
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> Site: http://www.Darkfalz.com
> Blog: http://blog.Darkfalz.com
>
>
> "Big E" <(E-Mail Removed)> wrote in message
> news:eQHGLW%(E-Mail Removed)...
> > I'm using VB in ASP.Net with SQL Server 2000.
> >
> > I have a States Combobox that lists the State. The State has a StateId

in
> > table states. When I do updates to various tables from the form I would

> like
> > to update the StateId not the StateName. I've looked at the datamember

and
> > datavalue stuff but don't understand it.
> >
> > Can anyone point me at a sample or some code they've used.
> >
> > Thanks.
> >
> > Big E
> >
> >
> >

>
>



 
Reply With Quote
 
Big E
Guest
Posts: n/a
 
      06-11-2004
Actually. When I try and retrieve the contents of the dropdownlist later the
Value has the equivalents of the text. When I loaded it with data in a loop
the value was 1 where the text was Alabama. Now later they both contain
Alabama.

Thanks.

Big E


TextBox1.Text = cboStateCompany.SelectedItem.Value

TextBox2.Text = cboStateCompany.SelectedItem.Text





"Curt_C [MVP]" <software_AT_darkfalz.com> wrote in message
news:uTFS1m%(E-Mail Removed)...
> Combo box or DropDownList?
> should be
> this.DropDownList1.SelectedItem.Value
> or
> this.DropDownList1.SelectedItem.Text
>
> --
> Curt Christianson
> Owner/Lead Developer, DF-Software
> Site: http://www.Darkfalz.com
> Blog: http://blog.Darkfalz.com
>
>
> "Big E" <(E-Mail Removed)> wrote in message
> news:eQHGLW%(E-Mail Removed)...
> > I'm using VB in ASP.Net with SQL Server 2000.
> >
> > I have a States Combobox that lists the State. The State has a StateId

in
> > table states. When I do updates to various tables from the form I would

> like
> > to update the StateId not the StateName. I've looked at the datamember

and
> > datavalue stuff but don't understand it.
> >
> > Can anyone point me at a sample or some code they've used.
> >
> > Thanks.
> >
> > Big E
> >
> >
> >

>
>



 
Reply With Quote
 
Justin Beckwith
Guest
Posts: n/a
 
      06-12-2004
Hey Big E,
the DataTextField and DataValueField properties of the dropdownlist
are actually pretty simple. In your states table, I am assuming you
have 2 rows. The stateID and the stateName. At design time, you want
to make the DataTextField of your dropdown "stateName", and your
DataValueField "stateID". When the form submits, you can simply look
at the value of the dropdownlist, and it should be the stateID. Hope
this helps!
 
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
Combobox Project: How to put 4 text items in the combobox christopher.m.lusardi@gmail.com Java 5 10-11-2012 09:29 PM
Populating a ComboBox in C# Al Wilkerson ASP .Net 7 08-22-2012 05:17 PM
Sync databound combobox to current bound record in form dbuchanan ASP .Net 6 02-02-2006 11:42 PM
ComboBox design-time DataBinding setting questions. dbuchanan ASP .Net 3 02-01-2006 12:15 PM
MY KINGDOM FOR AN HTML COMBOBOX kpg MCSE 16 01-12-2005 10:16 PM



Advertisments