?
Solved

combobox selected value in database

Posted on 2008-06-26
5
Medium Priority
?
2,927 Views
Last Modified: 2013-11-07
I have a combobox in an application which is in wpf and linq
 <ComboBox Height="23" HorizontalAlignment="Left" Margin="70,32.24,0,0" Name="cbGroup" VerticalAlignment="Top" Width="187" AllowDrop="True" SelectedIndex="0">
                            <ComboBoxItem>Adult</ComboBoxItem>
                            <ComboBoxItem>Youth</ComboBoxItem>
                            <ComboBoxItem>Children</ComboBoxItem>
                            <ComboBoxItem>Unknown</ComboBoxItem>
                        </ComboBox>

I am using the following code to insert the selected value in the database

 NewContact.AgeGroup = (string)this.cbGroup.SelectedValue.ToString();

but this  inserts in the database
System.Windows.Controls.ComboBoxItem: Children
please let me know how  i can insert the text value of the selected value in the database
0
Comment
Question by:shoopak
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21875905
try this
NewContact.AgeGroup = this.cbGroup.SelectedItem.Value.ToString();
0
 

Author Comment

by:shoopak
ID: 21877817
this doesn't work because

SelectedItem doesn't have a value property

This application is in wpf  and dot net 3.5


app.gif
0
 
LVL 11

Accepted Solution

by:
Mihai Stancescu earned 200 total points
ID: 21907998
Try this
NewContact.AgeGroup = this.cbGroup.Text;



Hope this helps!

Regards,
Mishu
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question