LIST DATA TO A DROP DOWN MENU IN ASP.NET WEB PAGE+VB SCRIPT [Resolved]

Posted by Baijuep under Regular Expressions on 3/16/2011 | Points: 10 | Views : 1877 | Status : [Member] | Replies : 4
i have a databse nemed workshop and table named menu with following fiedls
slno, int
sect,varchar(50),
veheqpt, varcahar(200)
i want to list nems from fiedl veheqpt to a dropdown menu in a asp.net web page+vb code

Baiju EP


Responses

Posted by: Baijuep on: 3/17/2011 [Member] Starter | Points: 25

Up
0
Down

Resolved
Thanks for your direction
i used the following
<asp:Dropdownlist id="atMyDropDownList" DataValueField = "veheqpt"
DataTextField = "veheqpt" runat="server" DataSourceID="SqlDataSource1" />

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:workshopConnectionString %>"
SelectCommand="SELECT [veheqpt] FROM [Menu]"></asp:SqlDataSource>

and it is working fine


Baiju EP

Baijuep, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nilkanthn on: 3/17/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Baijuep,

Try this code....

<asp:Dropdownlist id="atMyDropDownList" DataValueField = "veheqpt" DataTextField = "slno" runat="server" />


private Sub Page_Load(Sender as object, e as System.EventArgs)
dim sqlText as string = "select * from menu"
atMyDropDownList.DataSource = GetDr( sqlText )
atMyDropDownList.DataBind()
End Sub

private Function GetDr(sqlText as string) as SqlDataReader
dim dr as SqlDataReader
dim sqlConn as SqlConnection = new SqlConnection(ConnectionString())
dim sqlCmd as SqlCommand = new SqlCommand(sqlText,sqlConn)
sqlCmd.Connection.Open()
dr = sqlCmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
return dr
End Function


Thanks
Nilkanth

Baijuep, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gsolvers on: 3/17/2011 [Member] Starter | Points: 25

Up
0
Down
Perfect!

Best Regards,

VG
www.TeacherJi.com

Baijuep, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nilkanthn on: 3/18/2011 [Member] Starter | Points: 25

Up
0
Down
We are here to help you always.....

Thanks,
Nilkanth

Baijuep, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response