Solved

combobox selected value in database

Posted on 2008-06-26
5
2,915 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
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 50 total points
ID: 21907998
Try this
NewContact.AgeGroup = this.cbGroup.Text;



Hope this helps!

Regards,
Mishu
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now