多个部分的标识符"System.Data.DataRowView"被指定为"System.Data.DataRowView".无法绑定. [英] The multi-part identifier "System.Data.DataRowView" could not be bound.

查看:53
本文介绍了多个部分的标识符"System.Data.DataRowView"被指定为"System.Data.DataRowView".无法绑定.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法绑定多部分标识符"System.Data.DataRowView".
我在此plz中遇到此错误,可帮助我如何在下面的代码中对其进行纠正

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()
        {
            InitializeComponent();
        }

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

推荐答案

您的错误可能是这样的:
cbxEid.SelectedItem.ToString();

相反,请尝试使用cbxEid.SelectedItem.TextcbxEid.SelectedItem.Value
You error is probably this:
cbxEid.SelectedItem.ToString();

Instead, try with cbxEid.SelectedItem.Text or cbxEid.SelectedItem.Value


这篇关于多个部分的标识符"System.Data.DataRowView"被指定为"System.Data.DataRowView".无法绑定.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆