Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 05-02-2009
Member
 
Join Date: Jan 2009
Posts: 36
System.Data.DataRowView in combobox

Hi,

System.Data.DataRowView in combobox
That happens to me when I have misspelled the column name being assigned to
the DisplayMember property. I've found that both the spelling and the case
must match the column name.
Reply With Quote
  #2  
Old 05-02-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: System.Data.DataRowView in combobox

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"
Reply With Quote
  #3  
Old 05-02-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: System.Data.DataRowView in combobox

If what you want is the value from the column of the selected row, an easier
way might be to set :
cboSelectResource.ValueMember = "ResourceDetails";
then when you want to retrieve it:

string wholeRecord = cboSelectResource.SelectedValue

However, for this to work, you'll have to get the first problem resolved.

On the first problem, have you tried setting the DataSource to
dsResourceGroup.TableName instead of instead of dsResourceGroup.Tables[0]?
Substitute the actual name of the Table for TableName.

Can we assume that the column ResourceDetails is defined as a string and
that the Dataset dsResourceGroup has only the one Table in it?

Let me know if this works,
Reply With Quote
  #4  
Old 05-02-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: System.Data.DataRowView in combobox

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);
}
Reply With Quote
  #5  
Old 01-10-2009
Member
 
Join Date: Oct 2009
Posts: 1
Re: System.Data.DataRowView in combobox

Hi I get a different error.. I am using VB.net and creating a Window Application and my platform is VS 2005

My scenario is this..

I have 2 combobox and a textbox
when i select value from 1st combobox, it fetches the associated record from the db and populates the 2nd combobox.

My requirement is when i select value from 2nd combobox it should fetch the associated record from the db and display in the textfield.

2nd combobox can have multiple values but textfield would show only 1.

now my prob

when i select value from 1st combo, i can clearly see the 2nd combo populated with values, i expect... but i run into trouble when i try to read the value from the 2nd combo and run the query against the db... this is where i see System.Data.DataRowView.

following is my code

********************************************

this is to Populate 2nd combo

********************************************

cmdText = "Select Location_Name From Location_Details Where Region_Name=" + "'" & strRegionName & "'" + " " + "AND" + " " + "Location_Category=" + "'" & strLocationType & "'" + " " + "AND" + " " + "Location_Business_Group=" + "'" & strBUType & "'"

Try
sqlcmd = New SqlCommand(cmdText, sqlConn)
sqlDA = New SqlDataAdapter
sqlDA.SelectCommand = sqlcmd

sqlConn.Open()

'Creating the dataset and reading data into it

sqlDS = New DataSet
sqlDA.Fill(sqlDS, "Location_Details")
sqlDT = sqlDS.Tables("Location_Details")

cmbx_LocationName.DataSource = sqlDT
cmbx_LocationName.DisplayMember = "Location_Name"
cmbx_LocationName.ValueMember = "Location_Name"


'intLocationName = cmbx_LocationName.Items.Count

Catch ex As Exception

MessageBox.Show(ex.Message)
sqlConn.Close()

Finally
sqlConn.Close()

End Try
*************************************

***************************************
this is to read the value when the 2nd combo is clicked to select value
***************************************

strLocationName_Selected = cmbx_LocationName.SelectedItem.ToString

cmdText = "Select Location_Circuit_ID From Location_Details Where Location_Name=" + "'" & strLocationName_Selected & "'"

when i do a Messagebox.show(cmdText) I get this

Select Location_Circuit_ID From Location_Details Where Location_Name= 'System.Data.DataRowView'

I verified the DisplayMember and ValueMember and found the Column Name consistent and correct in both the application code as well as the db

Please help....
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "System.Data.DataRowView in combobox"
Thread Thread Starter Forum Replies Last Post
Need Help With ComboBox Reyas Software Development 1 29-04-2012 12:53 PM
Visual Studio Express: Delete data in a combobox Dino M Software Development 4 29-12-2010 01:34 AM
Use of combobox in script Martien Software Development 3 15-01-2010 11:58 AM
How to lock combobox JamesB Software Development 3 19-03-2009 07:20 PM
Add ComboBox in DataGrid in VB 6.0 Jateen Software Development 3 15-01-2009 06:31 PM


All times are GMT +5.5. The time now is 08:57 AM.