Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generics bound combobox
Message
From
20/09/2007 15:58:13
 
General information
Forum:
ASP.NET
Category:
.NET Compact Framework
Environment versions
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01255747
Message ID:
01255833
Views:
9
Well, as long as it works, we're both happy. Glad I could help. =0)

~~Bonnie



>Sorry if i confused you. I first changed the location where I fill up the glRuta and setting the SelectedValue manually worked as I expected. But after seeing your code I changed back to your suggestion and it also worked but with less code.
>
>Thanks again for your help!
>
>
>>But wait, this doesn't make sense ... I don't get what you're trying to do ... what happened to oCliente.Ruta?
>>
>>~~Bonnie
>>
>>
>>>Thanks for leading me in the right direction Bonnie, apparently the problem was that I was setting the binding properties before populating the list. Now it works with :
>>>
>>>
>>>   cboRuta.DataBindings.Add("SelectedValue", glRuta, "RutaId");
>>>
>>>
>>>>Initially I did it like this:
>>>>
>>>>
>>>>   cboRuta.DataBindings.Add("SelectedValue", glRuta, "RutaId");
>>>>
>>>>
>>>>But it did not work. I'll try it the way you suggested and let you know.
>>>>
>>>>>I have a quick question as to why you want to set the SelectedValue that way. Are you not binding this Combo to oCliente? If you do this, it should work without manually setting the SelectedValue:
>>>>>
>>>>>
>>>>>cboRuta.DataBindings.Add("SelectedValue", oCliente, "Ruta");
>>>>>
>>>>>
>>>>>~~Bonnie
>>>>>
>>>>>
>>>>>
>>>>>>Hi all, I have a generics list that I use to fill a combobox, I bound them like this:
>>>>>>
>>>>>>
>>>>>>    cboRuta.DisplayMember = "Descripcion";
>>>>>>    cboRuta.ValueMember = "RutaId";
>>>>>>    cboRuta.DataSource = glRuta;
>>>>>>
>>>>>>
>>>>>>That part works fine, but if I set the selectedvalue property it doesn't seems to affect the displayed member of the combobox.
>>>>>>
>>>>>>
>>>>>>    cboRuta.SelectedValue = oCliente.Ruta
>>>>>>
>>>>>>
>>>>>>What am I missing here?
>>>>>>
>>>>>>TIA, Enmanuel
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform