Click here to Skip to main content
16,004,452 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I got a combobox that i added items on design(on property items) now i want to read from database using it like
C#
cmbCurrentPhase.Text = read.GetValue(11).ToString();

but it doesnt diplay anything on combobox
Posted
Updated 15-Jul-12 22:45pm
v2
Comments
Sandeep Mewara 16-Jul-12 4:44am    
Incomplete. You need to share the full code snippet related to it and add more detail on what you mean by 'doesnt display'. Did you DEBUG?

try this.
C#
//ex. cmbCurrentPhase.Items.Add(new ListItem(read.GetValue(11).ToString(),"value"))
cmbCurrentPhase.Items.Add(new ListItem("Text","value"));
 
Share this answer
 
Hi,

try like this..

C#
cmbCurrentPhase.Items.FindByText(read.GetValue(11).ToString()).Selected = true;


this will work only if the string given by read.GetValue(11).ToString() exists in combobox items

hope it helps.
 
Share this answer
 
Comments
Mphirana 16-Jul-12 4:35am    
Thanks pal works
Karthik Harve 16-Jul-12 4:39am    
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