从数据库中选择标签 [英] populat select tag from DB
本文介绍了从数据库中选择标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
先生们,您好
所以我的问题很经典,但是我需要您的帮助来解决..
我正在使用一个选择标签,我想这样做:
Hi gentlemen
So my question is clasic but i need your help to resolve it ..
im working with a select tag and i want to do the same as that:
using cnn as new sqlConnection(cnnstr)
Dim cmmd As New SqlCommand(cmdstr, cnt)
cnn.open()
Dim dr As SqlDataReader = cmmd.ExecuteReader
While dr.Read()
DropDownList1.items.add(dr(0)
End While
dr.close()
end using
我不想使用数据源..我所需要做的就是填充Select标签,如DropDownList
非常感谢:-)
i don''t want to use the datasource .. All what i need is to fill Select tag like DropDownList
THANK YOU VERY MUCH :-)
推荐答案
尝试
DropDownList1.Items.Add(dr.GetValue(0).ToString).
但是使用数据绑定总是很好的.
Try
DropDownList1.Items.Add(dr.GetValue(0).ToString).
But it is always good to use databinding.
DropDownList1.DataSource = dr;
DropDownList1.DataTextField = "DispField"; //give proper name here
DropDownList1.DataValueField = "ValueField";//give proper name here
DropDownList1.DataBind();
这篇关于从数据库中选择标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文