I am a beginner at asp.net.
Here I have put data from a table into a dropdown list. I have only been able to get the leftmost column in the query to show. How can other columns be shown without combined them into 1 column like in the column r? For example, how can I include dxid?
Thanks.
<% @import namespace="system.data" %>
<% @import namespace="system.data.sqlclient" %>
<html>
<head>
<title>
</title>
<script language="vb" runat="server">
sub page_load(sender as object,e as eventargs)
if not page.ispostback
binddata()
end if
end sub
sub binddata()
dim connection1 as sqlconnection=new sqlconnection("server=111.111.11.11;uid=sa;pwd=aaaa;database=test")
const q1 as string="select code+' '+descriptor as r,dxid from icd9s where date_del is null order by code"
dim command1 as sqlcommand=new sqlcommand(q1,connection1)
connection1.open()
dim dr as sqldatareader=command1.executereader()
ddl1.datasource=dr
ddl1.databind()
connection1.close()
end sub
sub show(sender as object,e as eventargs)
l1.text="*"&left(ddl1.selecteditem.text,instr(ddl1.selecteditem.text,chr(32)))&"*"
end sub
</script>
</head>
<body>
<form runat="server">
<asp:dropdownlist id="ddl1" datatextfield="r" datavaluefield="dxid" runat="server"/>
<asp:button id="b1" text="click" onclick="show" runat="server" />
<asp:label id="l1" columns="8" runat="server" />
</form>
</body>
</html>
Here I have put data from a table into a dropdown list. I have only been able to get the leftmost column in the query to show. How can other columns be shown without combined them into 1 column like in the column r? For example, how can I include dxid?
Thanks.
<% @import namespace="system.data" %>
<% @import namespace="system.data.sqlclient" %>
<html>
<head>
<title>
</title>
<script language="vb" runat="server">
sub page_load(sender as object,e as eventargs)
if not page.ispostback
binddata()
end if
end sub
sub binddata()
dim connection1 as sqlconnection=new sqlconnection("server=111.111.11.11;uid=sa;pwd=aaaa;database=test")
const q1 as string="select code+' '+descriptor as r,dxid from icd9s where date_del is null order by code"
dim command1 as sqlcommand=new sqlcommand(q1,connection1)
connection1.open()
dim dr as sqldatareader=command1.executereader()
ddl1.datasource=dr
ddl1.databind()
connection1.close()
end sub
sub show(sender as object,e as eventargs)
l1.text="*"&left(ddl1.selecteditem.text,instr(ddl1.selecteditem.text,chr(32)))&"*"
end sub
</script>
</head>
<body>
<form runat="server">
<asp:dropdownlist id="ddl1" datatextfield="r" datavaluefield="dxid" runat="server"/>
<asp:button id="b1" text="click" onclick="show" runat="server" />
<asp:label id="l1" columns="8" runat="server" />
</form>
</body>
</html>