Click here to Skip to main content
15,908,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All...

I want only one value from database,How i can i retrieve that??

I have one combobox,that combobox display member=item name, when i select the item name from combobox means tha particular item id show in one textbox,the below code is add the datasoure in combobox with value member...
here itemselect=My combobox.

SQL
itemselect.DataSource = sp.datafill("select pu.item_id as puid,it.name as itemname from sales_items pu,items it where pu.item_id=it.id");
           itemselect.DisplayMember = "Itemname";
           itemselect.ValueMember = "id";
           itemselect.SelectedIndex = -1;


now how to show the item is in textbox?
pls send your ideas...
Posted

1 solution

I'm not exactly sure what you mean but if you just want to get the SelectedValue for the SelectedItem try using the ComboBox's SelectedIndexChange event. Something like this...

C#
private void itemselect_SelectedIndexChanged(object sender, EventArgs e)
{
    textBox1.Text = string.Empty;
    if (itemselect.SelectedIndex > -1)
    {
        textBox1.Text = itemselect.SelectedValue.ToString();
    }
}
 
Share this answer
 
Comments
sv sathish 4-Oct-13 14:46pm    
Thank you so mush sir..
idenizeni 4-Oct-13 14:51pm    
You're welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900