如下
DropDownList1.DataSource= DR
DropDownList1.DataTextField = "你要显示的字段名"
DropDownList1.DataValueField = "你希望获得的值"
DropDownList1.DataBind参考
ms-help://MS.VSCC/MS.MSDNVS.2052/cpref/html/frlrfSystemWebUIWebControlsDropDownListMembersTopic.htm
DropDownList1.DataSource= DR
DropDownList1.DataTextField = "你要显示的字段名"
DropDownList1.DataValueField = "你希望获得的值"
DropDownList1.DataBind参考
ms-help://MS.VSCC/MS.MSDNVS.2052/cpref/html/frlrfSystemWebUIWebControlsDropDownListMembersTopic.htm
解决方案 »
- QQ聊天工具是B/S还是C/S架构的?
- .net更新数据时自动刷新页面?
- aspx如何调用文件
- 登陆后采集Jsp页面输出的图片,也许是几行代码50RMB,掏宝直接给
- 求救(急):TableAdapter(Optimistic Concurrency Enable)和ObjectDataSource更新数据的空值问题
- ---------HttpContextresponse.WriteFile(FileName)的文件很大,输出很慢,又没有更快的办法。-------------
- 如何在Repeater中的LinkButton中添加一个删除确认????
- 50分!~小弟有一个项目的源代码。但是调试不好。高手帮我调一下。
- 有没有可能把hashtable 做 datagrid的数据源?
- 这是什么问题··救救我啊··
- 装上visual Studio.net后原ASP的程序为什么不打打开数据库
- 为什么只能传递两个汉字?有解决的办法吗?
DropDownList1.DataTextField = "你要显示的字段名"
DropDownList1.DataValueField = "你希望获得的值"
DropDownList1.DataBind
Dim myConnString As String = "Data Source=169;User ID=device;Password=list"
dim myConnection As new OracleConnection (myConnString)
dim mycommand as oraclecommand=new oraclecommand("select device_name from device_type",myconnection)
myConnection.Open()
dim DR as oracledatareader
DR=mycommand.Executereader
DataGrid1.DataSource= DR
DataGrid1.DataBind
DropDownList1.DataSource= DR
DropDownList1.DataTextField = "device_name"
DropDownList1.DataValueField = "name"
DropDownList1.DataBind
myConnection.Close()
End Sub</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
</p>
<p>
<asp:DropDownList id="DropDownList1" runat="server" Width="166px"></asp:DropDownList>
</p>
<p>
<asp:DataGrid id="DataGrid1" runat="server"></asp:DataGrid>
</p>
<!-- Insert content here -->
</form>
</body>
</html>
或者不将dr绑定到datagrid
或者先将dr绑定到dropdownlist
我没有试过,你试试
代码如下:
怎么回事呢??谢谢!!
sub Page_Load(Src As Object,E As EventArgs)
Dim myConnString As String = "Data Source=169;User ID=device;Password=list"
dim myConnection As new OracleConnection (myConnString)
dim mycommand as oraclecommand=new oraclecommand("select device_name from device_type",myconnection)
myConnection.Open()
dim DR as oracledatareader
DR=mycommand.Executereader
DropDownList1.DataSource=DR
DropDownList1.DataTextField = "device_name"
DropDownList1.DataValueField = "device_name"
DropDownList1.DataBind()
End Sub
Sub Button1_Click(sender As Object, e As EventArgs)
Label1.Text=DropDownList1.SelectedItem.Text
End Sub</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
</p>
<p>
<asp:DropDownList id="DropDownList1" runat="server" Width="309px"></asp:DropDownList>
</p>
<p>
<asp:Label id="Label1" runat="server"></asp:Label>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Button"></asp:Button>
</p>
<!-- Insert content here -->
</form>
</body>
</html