Saturday, September 16, 2006

Cannot bind to the new display member

I am working on an internal "report generator" tool at work. One of the forms has a listbox control. This is what I was trying to do:


' myHashTable holds objects of type "Report"
ListBox.DataSource = myHashTable.Values
ListBox.DisplayMember = "ReportName"
ListBox.ValueMember = "ReportCode"


This looks pretty straight forward. But when I ran the code, I got "Cannot bind to the new value member" exception. Googling this error did not get me anywhere. While mucking aound with the code I changed "ReportName" and "ReportCode" in my "Report" class from members to properties. And WALLA this worked!!

Hopefully this post will save someone a headache.

Comments:
This is happening to me today, except, I'm binding directly from a dataset... Any ideas?
 
Got it. A silly error message for a silly error. I had a query with a union, and the column names didn't match. Something like this:

select code1
from table1
union
select code2
from table2

Fixed it by doing this:

select code1 as code
from table1
union
select code2 as code
from table2

Hope this helps someone else to fix this problem quickly and easily.
 
Thanks - I had that same problem and you saved me (well, you and google that is)
 
same for me... thanks...
 
Same for me too :) Thanks
 
Hi
[url=http://www.gotitans.com/gochat/chat/images/smilies/toyota.html]toyota[/url]
[url=http://www.gotitans.com/gochat/chat/images/smilies/bentley-dierks.html]bentley dierks[/url]
[url=http://www.gotitans.com/gochat/chat/images/smilies/honda.html]honda[/url]
[url=http://www.gotitans.com/gochat/chat/images/smilies/lincoln.html]lincoln[/url]
[url=http://www.gotitans.com/gochat/chat/images/smilies/chrysler.html]chrysler[/url]
[url=http://www.gotitans.com/gochat/chat/images/smilies/chevrolet.html]chevrolet[/url]
[url=http://www.gotitans.com/gochat/chat/images/smilies/buick.html]buick[/url]
[url=http://www.gotitans.com/gochat/chat/images/smilies/mercury.html]mercury[/url]
[url=http://www.gotitans.com/gochat/chat/images/smilies/nissan.html]nissan[/url]
[url=http://www.gotitans.com/gochat/chat/images/smilies/ford.html]ford[/url]
 
Good day to everyone
[url=http://www.yagoda.pl/pgp/hotchkiss-co-real-estate.html]hotchkiss co real estate[/url]
[url=http://www.yagoda.pl/pgp/mazda.html]mazda[/url]
[url=http://www.yagoda.pl/pgp/citroen.html]citroen[/url]
[url=http://www.yagoda.pl/pgp/santana.html]santana[/url]
[url=http://www.yagoda.pl/pgp/ultima.html]ultima[/url]
[url=http://www.yagoda.pl/pgp/paige.html]paige[/url]
[url=http://www.yagoda.pl/pgp/humber-college.html]humber college[/url]
[url=http://www.yagoda.pl/pgp/mclaren.html]mclaren[/url]
[url=http://www.yagoda.pl/pgp/estate-real-speedwell-tn.html]estate real speedwell tn[/url]
[url=http://www.yagoda.pl/pgp/jennifer-hudson.html]jennifer hudson[/url]
[url=http://www.yagoda.pl/pgp/apollo.html]apollo[/url]
[url=http://www.yagoda.pl/pgp/climax.html]climax[/url]
 
Hi folks
[url=http://www.yagoda.pl/pgp/herrington-marmon.html]herrington marmon[/url]
[url=http://www.yagoda.pl/pgp/durant-kevin.html]durant kevin[/url]
[url=http://www.yagoda.pl/pgp/lagonda.html]lagonda[/url]
[url=http://www.yagoda.pl/pgp/geo.html]geo[/url]
[url=http://www.yagoda.pl/pgp/barnes-and-noble.html]barnes and noble[/url]
[url=http://www.yagoda.pl/pgp/international-harvester.html]international harvester[/url]
[url=http://www.yagoda.pl/pgp/edsel.html]edsel[/url]
[url=http://www.yagoda.pl/pgp/audi.html]audi[/url]
[url=http://www.yagoda.pl/pgp/abt.html]abt[/url]
[url=http://www.yagoda.pl/pgp/waltham.html]waltham[/url]
[url=http://www.yagoda.pl/pgp/gdt.html]gdt[/url]
[url=http://www.yagoda.pl/pgp/dc-design.html]dc design[/url]
[url=http://www.yagoda.pl/pgp/triumph.html]triumph[/url]
[url=http://www.yagoda.pl/pgp/faw.html]faw[/url]
 
Cepasa amigos ))
[url=http://www.exoticdancewear.co.uk/images/linda/group-sex.html]group sex[/url]
[url=http://www.exoticdancewear.co.uk/images/linda/asian-girl.html]asian girl[/url]
[url=http://www.exoticdancewear.co.uk/images/linda/hardcore.html]hardcore[/url]
[url=http://www.exoticdancewear.co.uk/images/linda/lesbian.html]lesbian[/url]
[url=http://www.exoticdancewear.co.uk/images/linda/big-penis.html]big penis[/url]
[url=http://www.exoticdancewear.co.uk/images/linda/anal-sex.html]anal sex[/url]
[url=http://www.exoticdancewear.co.uk/images/linda/gay.html]gay[/url]
[url=http://www.exoticdancewear.co.uk/images/linda/big-pussy.html]big pussy[/url]
[url=http://www.exoticdancewear.co.uk/images/linda/ebony-porn.html]ebony porn[/url]
[url=http://www.exoticdancewear.co.uk/images/linda/amateur.html]amateur[/url]
[url=http://www.exoticdancewear.co.uk/images/linda/arab-sex.html]arab sex[/url]
[url=http://www.exoticdancewear.co.uk/images/linda/fetish.html]fetish[/url]
[url=http://www.exoticdancewear.co.uk/images/linda/anal.html]anal[/url]
[url=http://www.exoticdancewear.co.uk/images/linda/gay-anal.html]gay anal[/url]
 
'Move .Datasource to last row
ListBox.DisplayMember = "ReportName"
ListBox.ValueMember = "ReportCode"
ListBox.DataSource = myHashTable.Values
 
I had this error when the DisplayMember was missing from the control's DataSource (which was a DataTable).
 
I had a similar problem. Thanks.
 
Exactly the same problem but one more silly requirement is we must make them public properties.
 
My problem was that the user did not have permissions to access the stored procedure the datasource was set at. It was hard to catch because I was not getting any errors when testing from my machine
 
Thank you!
 
I already got the headache, but at least this helped me solve the problem! Of course, after looking more closely at the DisplayMember documentation, I can see that it is listed as a property. Seems strange!
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?