How to display combobox values in textbox?

Posted by Hariinakoti under C# on 4/12/2012 | Points: 10 | Views : 7130 | Status : [Member] | Replies : 6
Hi,
In my task combobox is there.In this combo i have some itemcodes.Now i want to item names in textbox based on that item code.
I wrote this code but it is not working.Item code is integer value not a string.I tried all ways..

private void cmbitemcode_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbitemcode.SelectedValue=="101")
{
txtitemname.Text = "Samosa";
}
if (cmbitemcode.SelectedValue == "102")
{
txtitemname.Text = "Cake";
}
if (cmbitemcode.SelectedValue == "103")
{
txtitemname.Text = "Biscuits";
}
else
{
}

}

Thanks & Regards
Hari



Responses

Posted by: Hariinakoti on: 4/12/2012 [Member] Starter | Points: 25

Up
0
Down
@Dotenetfunda team

Any one give reply to me urgently..

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 4/13/2012 [Member] Starter | Points: 25

Up
0
Down
I got solution don't reply my question

Thanks & Regards
Hari

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Leila on: 4/13/2012 [Member] Starter | Points: 25

Up
0
Down
Can you post your answer?

Thanks,
Leila

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/13/2012 [Member] Silver | Points: 25

Up
0
Down
if u post ur answer it helps to others..

Regards,
Singaravel M

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/13/2012 [Member] Silver | Points: 25

Up
0
Down
i don't know wat code u used.. in this case we can use following code in combobox event..

textbox1.text=comboBox1.SelectedItem()

Regards,
Singaravel M

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sarathy.Mca on: 4/13/2012 [Member] Starter | Points: 25

Up
0
Down
Hi use this code it will be working

Before you write this code you can check the dropdown or combo box"AUTOPOSTBACK " property is TRUE, if its true then the code work properly else will you set as TRUE.

if (cmbitemcode.SelectedValue == "101")
{
txtitemname.Text = "Samosa";
}
else if (cmbitemcode.SelectedValue == "102")
{
txtitemname.Text = "Cake";
}
else if (cmbitemcode.SelectedValue == "103")
{
txtitemname.Text = "Biscuits";
}
else
{
txtitemname.Text = "Doesn't have value";
}

Parthasarathy.S

Hariinakoti, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response