Results 1 to 5 of 5

Thread: System.Data.DataRowView in combobox

  1. #1
    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.

  2. #2
    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"

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    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,

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    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);
    }

  5. #5
    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....

Similar Threads

  1. Need Help With ComboBox
    By Reyas in forum Software Development
    Replies: 1
    Last Post: 29-04-2012, 12:53 PM
  2. Visual Studio Express: Delete data in a combobox
    By Dino M in forum Software Development
    Replies: 4
    Last Post: 29-12-2010, 01:34 AM
  3. Use of combobox in script
    By Martien in forum Software Development
    Replies: 3
    Last Post: 15-01-2010, 11:58 AM
  4. How to lock combobox
    By JamesB in forum Software Development
    Replies: 3
    Last Post: 19-03-2009, 07:20 PM
  5. Add ComboBox in DataGrid in VB 6.0
    By Jateen in forum Software Development
    Replies: 3
    Last Post: 15-01-2009, 06:31 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,129,403.24098 seconds with 16 queries