从DB填充DropDownList [英] populate DropDownList from DB

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

问题描述



有人能告诉我如何从Data Base填充DropdownList。我用
使用ASP.NET / C#/ MS SQL SERVER。


谢谢!


Viktor
---

外发邮件已通过无病毒验证。

由AVG反病毒系统检查( http://www.grisoft.com)

版本:6.0.721 /病毒库:477 - 发布日期:16.7.2004 a。

Hi,
Could someone tell me how can be populated DropdownList from Data Base. I
use ASP.NET/C#/MS SQL SERVER.

Thanks!

Viktor
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.721 / Virus Database: 477 - Release Date: 16.7.2004 a.

推荐答案

Victor,


您需要获取数据库数据在数据集中,将DropdownList

属性DataSource设置为数据集名称,将DataMember设置为表名

并调用DataBind方法。


Eliyahu


" Viktor Popov" < 6 **** @ yahoo.com>在消息中写道

新闻:OM ************* @ TK2MSFTNGP12.phx.gbl ...
Victor,

You need to get the database data into a dataset, set the DropdownList
properties DataSource to the dataset name and DataMember to the table name
and call DataBind method.

Eliyahu

"Viktor Popov" <vi****@yahoo.com> wrote in message
news:OM*************@TK2MSFTNGP12.phx.gbl...

有人能告诉我如何从Data Base填充DropdownList。我使用ASP.NET / C#/ MS SQL SERVER。

谢谢!

Viktor

---
发送邮件经过无病毒认证。
由AVG反病毒系统检查( http:// www.grisoft.com)
版本:6.0.721 /病毒数据库:477 - 发布日期:16.7.2004 a。
Hi,
Could someone tell me how can be populated DropdownList from Data Base. I
use ASP.NET/C#/MS SQL SERVER.

Thanks!

Viktor
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.721 / Virus Database: 477 - Release Date: 16.7.2004 a.



感谢您的回复!


您可以添加其他代码吗?


SqlConnection conn = new SqlConnection(" ;数据来源= BLEK;初始

目录=遗产;用户ID = blek;密码= banderas");


SqlDataAdapter da = new SqlDataAdapter("选择* FROM blek.TypeOffer",

conn);

DataSet ds = new DataSet();


da。 Fill(ds,Table);


DropDownList2.DataSource = ds;


---

外发邮件已通过无病毒验证。

由AVG反病毒系统检查词干( http://www.grisoft.com)

版本:6.0.729 /病毒数据库:484 - 发布日期:27.7.2004 a。

Thanks for the reply!

Could you add the other code?

SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");

SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
conn);
DataSet ds = new DataSet();

da.Fill (ds,"Table");

DropDownList2.DataSource = ds;


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.


DropDownList2.DataMember =" Table";

DataBind(); //或DropDownList2.DataBind();

" Viktor Popov" < 6 **** @ yahoo.com>在消息中写道

新闻:%2 ****************** @ TK2MSFTNGP09.phx.gbl ...
DropDownList2.DataMember = "Table";
DataBind (); // or DropDownList2.DataBind ();
"Viktor Popov" <vi****@yahoo.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
谢谢你的回复!

你能添加其他代码吗?

SqlConnection conn = new SqlConnection(" Data Source = BLEK; Initial
Catalog = Estate;用户ID = blek;密码= banderas");

SqlDataAdapter da = new SqlDataAdapter(" Select * FROM blek.TypeOffer",
conn);

DataSet ds = new DataSet();

da.Fill(ds," Table");

DropDownList2.DataSource = ds;


---
发送邮件经过无病毒认证。
由AVG反病毒系统检查( http://www.grisoft.com)
版本:6.0.729 /病毒库:484 - 发布日期:27.7.2004 a。
Thanks for the reply!

Could you add the other code?

SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");

SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
conn);
DataSet ds = new DataSet();

da.Fill (ds,"Table");

DropDownList2.DataSource = ds;


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.



这篇关于从DB填充DropDownList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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