DropDown的DataSource / DataMember [英] DropDown's DataSource/DataMember

查看:61
本文介绍了DropDown的DataSource / DataMember的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我想我已经盯着它,直到它让我变得愚蠢(呃?)。我错过了什么

关于设置下拉列表以显示从表中提取的数据?


// ...

daPrepaid.Fill(dsPrepaid," Seller");

cboSeller.DataSource = dsPrepaid.Tables [" Seller"];

cboSeller.DisplayMember ="名称" ;;

// ...


当我分配数据源时,下拉菜单的Text属性变为

System.Data.DataRowView,这也是列表中唯一的项目。

我看不到的愚蠢的事情是什么?


TIA,


John

Hi all,

I think I''ve stared at it until it''s made me stupid(er?). What am I missing
about setting the list of the dropdown to display data pulled from a table?

//...
daPrepaid.Fill(dsPrepaid, "Seller");
cboSeller.DataSource = dsPrepaid.Tables["Seller"];
cboSeller.DisplayMember = "Name";
//...

When I assign the datasource, the dropdown''s Text property changes to
"System.Data.DataRowView", which is then the only item in the list as well.
What''s the stupid thing I''m not seeing?

TIA,

John

推荐答案

你不想错过cboSeller .ValueMember = QUOT;名称英寸; < - 或者其他什么领域?


Greg


" John Spiegel" < JS ****** @ YETANOTHERSPAMHATERc-comld.com>在消息中写道

新闻:eL ************** @ TK2MSFTNGP10.phx.gbl ...
Aren''t you missing the cboSeller.ValueMember="Name"; <-- or whatever field ?

Greg

"John Spiegel" <js******@YETANOTHERSPAMHATERc-comld.com> wrote in message
news:eL**************@TK2MSFTNGP10.phx.gbl...
大家好,

我想我已经盯着它,直到它让我变得愚蠢(呃?)。关于设置下拉列表以显示从
表中提取的数据,我有什么遗失


// ...
daPrepaid。填写(dsPrepaid,卖方);
cboSeller.DataSource = dsPrepaid.Tables [" Seller"];
cboSeller.DisplayMember =" Name";
// ...

当我分配数据源时,下拉列表的Text属性变为
" System.Data.DataRowView",这是列表中唯一的项目
好吧。
我没看到什么愚蠢的东西?

TIA,

John
Hi all,

I think I''ve stared at it until it''s made me stupid(er?). What am I
missing
about setting the list of the dropdown to display data pulled from a
table?

//...
daPrepaid.Fill(dsPrepaid, "Seller");
cboSeller.DataSource = dsPrepaid.Tables["Seller"];
cboSeller.DisplayMember = "Name";
//...

When I assign the datasource, the dropdown''s Text property changes to
"System.Data.DataRowView", which is then the only item in the list as
well.
What''s the stupid thing I''m not seeing?

TIA,

John


John,


我认为更改是名称。在错误的情况下,甚至没有在你的选择中使用

..


这是因为你使用三个单词cbo(combobox)和DropDown。


当cbo是一个网页下拉列表时,它很容易。

你想念

cboSeller.DataBind();


我希望这有帮助吗?


Cor
John,

A change is in my opinion that "Name" is in the wrong case or even not in
your select..

That because you use three words cbo (combobox) and DropDown.

When cbo is a webpage dropdownlist than it is easy.
You miss
cboSeller.DataBind();

I hope this helps?

Cor


嘿格雷格,


我收到了,但收到了错误。奇怪的是,当我这样做时,包括ValueMember在内的
,错误信息表明绑定到了一个问题

DisplayMember,更具体地来说:


无法绑定到新的显示成员。

参数名称:newDisplayMember


一个较少缩写的片段...


OleDbCommand cmdPrepaid = conPrepaid.CreateCommand();

cmdPrepaid.CommandType = CommandType.Text;

cmdPrepaid.CommandText =" SELECT * FROM PrepaidSeller";

daPrepaid = new OleDbDataAdapter();

daPrepaid.SelectCommand = cmdPrepaid;

dsPrepaid = new DataSet();

conPrepaid.Open();

尝试

{

daPrepaid.Fill(dsPrepaid," Seller");


cboSeller.DataSource = dsPrepaid.Tables [" Seller"];

cboSeller.DisplayMember =" EntityName";

cboSeller.ValueMember = CustKey;

// ...

}

谢谢,


John


" Greg Burns" < greg_burns@DONT_SPAM_ME_hotmail.com>在留言中写道

新闻:%2 **************** @ TK2MSFTNGP15.phx.gbl ...
Hey Greg,

I had it in, but was getting an error. The strange thing is when I do
include ValueMember, the error message indicates a problem with binding to
DisplayMember, more specifically:

Could not bind to the new disply member.
Parameter name: newDisplayMember

A less abbreviated snippet...

OleDbCommand cmdPrepaid = conPrepaid.CreateCommand();
cmdPrepaid.CommandType = CommandType.Text;
cmdPrepaid.CommandText = "SELECT * FROM PrepaidSeller";
daPrepaid = new OleDbDataAdapter();
daPrepaid.SelectCommand = cmdPrepaid;
dsPrepaid = new DataSet();
conPrepaid.Open();
try
{
daPrepaid.Fill(dsPrepaid, "Seller");

cboSeller.DataSource = dsPrepaid.Tables["Seller"];
cboSeller.DisplayMember = "EntityName";
cboSeller.ValueMember = "CustKey";
//...
}

Thanks,

John

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
Aren'你错过了cboSeller.ValueMember =" Name" ;; < - 或任何字段

Greg

John Spiegel < JS ****** @ YETANOTHERSPAMHATERc-comld.com>在消息中写道
新闻:eL ************** @ TK2MSFTNGP10.phx.gbl ...
Aren''t you missing the cboSeller.ValueMember="Name"; <-- or whatever field ?
Greg

"John Spiegel" <js******@YETANOTHERSPAMHATERc-comld.com> wrote in message
news:eL**************@TK2MSFTNGP10.phx.gbl...
大家好,
表中提取的数据,我有什么遗失


// ...
daPrepaid。填写(dsPrepaid,卖方);
cboSeller.DataSource = dsPrepaid.Tables [" Seller"];
cboSeller.DisplayMember =" Name";
// ...

当我分配数据源时,下拉列表的Text属性变为
" System.Data.DataRowView",这是列表中唯一的项目
好吧。
我没看到什么愚蠢的东西?

TIA,

John
Hi all,

I think I''ve stared at it until it''s made me stupid(er?). What am I
missing
about setting the list of the dropdown to display data pulled from a
table?

//...
daPrepaid.Fill(dsPrepaid, "Seller");
cboSeller.DataSource = dsPrepaid.Tables["Seller"];
cboSeller.DisplayMember = "Name";
//...

When I assign the datasource, the dropdown''s Text property changes to
"System.Data.DataRowView", which is then the only item in the list as
well.
What''s the stupid thing I''m not seeing?

TIA,

John



这篇关于DropDown的DataSource / DataMember的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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