-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: suganyasethupathy
Message 7 in Discussion
Hi Prasanth, As per your doubt in dropdownlist control, i worked it out with an
example in ASP.Net. Its working fine for me if you have fill the value for first
dropdownlist in pageload event and fill the value for second dropdownlist in
selectedindexchanged event of previous one. say, i have drpDept dropdownlist
control and drpReportingto dropdownlist control In Form Page_load event, the
code is as follows : Note: connection , command object is declared as public (
ofcourse, you can use same connection and command object for populating two dropdowns)
Objcmd = New SqlCommand("select * from masdepartment", Objconn)
Objcmd.CommandType = CommandType.Text
Objconn.Open()
Dim dreader As SqlDataReader
dreader = ObjCmd.ExecuteReader
If Not IsPostBack Then
drpdept.DataSource = dreader
drpdept.DataTextField = "deptname"
drpdept.DataValueField = "deptcode"
drpdept.DataBind()
End If
Objconn.Close()
So, the above code will populate drpdept dropdownlist. In
drpdept_SelectedIndexChanged event, the code is as follows:
Dim selval As String
selval = drpdept.SelectedItem.Value
Objcmd = New SqlCommand("select reportingto from masemployee where deptcode='" &
selval & "'", Objconn)
ObjCmd.CommandType = CommandType.Text
Objconn.Open()
Dim dreaderrep As SqlDataReader
dreaderrep = ObjCmd.ExecuteReader
drpRep.DataSource = dreaderrep
drpRep.DataTextField = "reportingto"
drpRep.DataBind()
Objconn.Close() So, the above code will populate drpReportingto dropdownlist.
regards, Suganya
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]