Re: Fill Combo :: "System.data.dataRowView"

  • Thread starter Thread starter Peter Foot [MVP]
  • Start date Start date
P

Peter Foot [MVP]

This is a symptom of the FieldName supplied in

Me.cboProductName.DisplayMember = "ProductName"

being incorrect. If this does not exactly match to a valid fieldname (Case
Sensitive) exposed by the collection you will get:-

"System.Data.DataRowView"



Peter

--
Peter Foot
Windows Embedded MVP

In The Hand
http://www.inthehand.com
Handheld Interactive Reference Guides
 
Hi,

Thanks for your Help. It Worked.

But one thing is very strange for me; "How could something be case sensitive
in a non-case-sensitive language like VB .NET?"

Anyways, Thanks again for your help.

WSM
 
Does it work if you cast the selected item to a string:-
Me.cboProductName.SelectedItem().ToString()

Although the item is displayed as a string it is actually a generic
"Object".



Peter
--
Peter Foot
Windows Embedded MVP

In The Hand
http://www.inthehand.com
Handheld Interactive Reference Guides
 
I ran into the exact same issue. I ended up wrapping a Try/Catch handler
around the code and explictly catch the cast error and ignore it. Something
like this:

try
{
int myId = (int)myCombo.SelectedValue;

// more code here
}
catch (InvalidCastException)
{
// do nothing
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
 
Back
Top