会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
程序
代码
博客园
首页
新随笔
联系
管理
订阅
绑定 DropDownList
绑定 DropDownList
注:ds为DataSet
DataTable table
=
ds.Tables[
"
mytable
"
];
foreach
(DataRow row
in
table.Rows)
{
mylist.Items.Add(
new
ListItem(row[
1
].ToString(),row[
0
].ToString()));
}
也可以用
mylist.DataSource
=
ds.Tables[
"mytable
"
].DefaultView;
mylist.DataTextField
=
"tn
ame
"
;
mylist.DataValueField
=
"tid
"
;
mylist.DataBind();
注:BindList()最好写在OnInit中
Web 窗体设计器生成的代码
#region
Web 窗体设计器生成的代码
override
protected
void
OnInit(EventArgs e)
{
//
//
CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
myConn
=
new
SqlConnection(strConn);
base
.OnInit(e);
BindList();
}
posted @
2008-10-05 10:20
hb
阅读(
178
) 评论(
0
)
收藏
举报
刷新页面
返回顶部
公告