我无法转换'system.data.datarowview'类型的对象来键入'system.iconvertible'这种类型的错误 [英] i have unable to cast object of type 'system.data.datarowview' to type 'system.iconvertible' this type of error

查看:111
本文介绍了我无法转换'system.data.datarowview'类型的对象来键入'system.iconvertible'这种类型的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法将'system.data.datarowview'类型的对象转换为'system.iconvertible'类型

i有这种类型的错误PLZ帮助我任何人

  private   void  BindClassGroupCmb()
{
// 显示现有记录列表。
尝试
{

ClassGroup = _ExcuteData._ExecuteDataSet( SELECT class_group_name,class_groupid来自class_group_master);
// cmbClassGroup.Items.Insert(0,--Select - );
cmbClassGroup.DataSource = ClassGroup.Tables [ 0 ];

cmbClassGroup.DisplayMember = class_group_name;
cmbClassGroup.ValueMember = class_groupid;
}
catch (Exception ex)
{
MessageBox.Show( 错误: + ex.Message, Error,MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}

解决方案

试试这样





 cmbClassGroup.DisplayMember =   class_group_name ; 
cmbClassGroup.ValueMember = class_groupid;
cmbClassGroup.DataSource = ClassGroup.Tables [ 0 ];





你必须在分配数据源 Valuemember Displaymember $ C> ...


unable to cast object of type 'system.data.datarowview' to type 'system.iconvertible'
i have this type of error plz help me anyone

private void BindClassGroupCmb()
{
    //Show existing record list.
    try
    {

        ClassGroup = _ExcuteData._ExecuteDataSet("SELECT class_group_name, class_groupid from class_group_master ");
       //cmbClassGroup.Items.Insert(0, "--Select--");
        cmbClassGroup.DataSource = ClassGroup.Tables[0];

        cmbClassGroup.DisplayMember = "class_group_name";
        cmbClassGroup.ValueMember = "class_groupid";
    }
    catch (Exception ex)
    {
        MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}

解决方案

Try like this


cmbClassGroup.DisplayMember = "class_group_name";
        cmbClassGroup.ValueMember = "class_groupid";
        cmbClassGroup.DataSource = ClassGroup.Tables[0];



you have to define the Valuemember and Displaymember before assigning a datasource...


这篇关于我无法转换'system.data.datarowview'类型的对象来键入'system.iconvertible'这种类型的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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