ASP.NET基础教程-DropDownList控件的使用
2008-01-06 10:34:08
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://chenxing.blog.51cto.com/240526/58184 |
//清除控件的内容
DropDownList.Items.Clear();
//打开数据库
con.Open();
//从数据库中提取数据
SqlCommand comm=new SqlCommand("select dept from dept",con);
//声明数据读取对象,并加载数据
SqlDataReader dr=comm.ExecuteReader();
//循环将数据添加到列表控件中
while(dr.Read ())
{
DropDownList.Items.Add(dr.GetString (dr.GetOrdinal (“dept")));
}
//关闭数据库
con.Close();
![]() 本文出自 “半瓶香油-好男人时来运转” 博客,请务必保留此出处http://chenxing.blog.51cto.com/240526/58184 本文出自 51CTO.COM技术博客 |



晨星
博客统计信息
热门文章
最新评论
友情链接

