Click here to Skip to main content
13,046,337 members (127,968 online)
Rate this:
Please Sign up or sign in to vote.
See more:
The multi-part identifier "System.Data.DataRowView" could not be bound.
I am getting this error in this plz help me to how to rectify it in the below code
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace DiscntdRtrvng
    public partial class DiscntdRtrvng : Form
        SqlConnection con = new SqlConnection("server=.;user id=sa;password=123;database=Seed_Employee");
        SqlCommand cmd;
        DataSet ds;
        SqlDataAdapter da;
        string s;
        public DiscntdRtrvng()
        private void DiscntdRtrvng_Load(object sender, EventArgs e)
            s = "select EmpId from Employee";
            da = new SqlDataAdapter(s, con);
            ds = new DataSet();
            da.Fill(ds, "emp");
           // DataRow row = ds.Tables[0].Rows[0];
            cbxEid.DataSource = ds.Tables[0];
            cbxEid.DisplayMember = "EmpId";
           //dataGridView1.DataSource = ds.Tables[0];
        private void cbxEid_SelectedIndexChanged(object sender, EventArgs e)
            s = "select * from Employee where EmpId=" + cbxEid.SelectedItem.ToString();
            da = new SqlDataAdapter(s, con);
            ds = new DataSet();
            da.Fill(ds, "emp");
            dataGridView1.DataSource = ds.Tables[0];
Posted 30-Jul-12 3:22am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You error is probably this:

Instead, try with cbxEid.SelectedItem.Text or cbxEid.SelectedItem.Value
Yogesh_Mishra 22-Jan-13 13:56pm
code don't work.
sjelen 23-Jan-13 5:48am
This is absolutely correct way to get selected value from DropDown control.
If it doesn't work for you, you have a problem elsewhere or you're doing it wrong.

Down-voting an answer without explanation is rude.
Yogesh_Mishra 23-Jan-13 10:18am
sorry, but for my code shown below,

ds = obj.SelectRecord("select * from library where bookid = " + combobid.SelectedItem.Text);

im getting error as :

Error 1 'object' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

if you have solution for this please comment,
sjelen 23-Jan-13 10:50am
Is this error exactly on this line of code? What type of object is 'combobid'?
What kind of application are you making: web-forms, MVC, win-forms, WPF, SilverLight?

I can't help you without more info.

I guess you're making desktop application. My original solution is for web application.
You should use 'combobid.SelectedText' or 'combobid.SelectedValue.ToString()',
depending on how you bind data to combo box.
siddharth629 15-Jan-14 3:47am
use this 'cbxEid.SelectedItem.ToString()'; or '"cbxEid.SelectedItem.ToString()"' it may be help u

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 30 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100