populating dependent dropdown list from a table in oracle.

Hi,
how to populate dependent dropdownlist from oracle database table.
i have 2 dropdownlist one used for country and other for state.if user selects dropdownlist country as southamerica then states in southamerica should be populated in second dropdownlist.
Thank you
using asp.net/oracle/.net2.0
tracy_pAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oleggoldCommented:
0
oleggoldCommented:
<aspataGrid id="Datagrid2" runat="server" Cssclass="txtTen" Width="600px"
Height="35px" Font-Size="9px" Font-Names="Verdana"
AutoGenerateColumns="False" Visible="True" BackColor="#FCFBEB"
BorderColor="#FFC0C0">

<HeaderStyle Font-Size="9px" Font-Names="Verdana"
Font-Bold="True"></HeaderStyle>

<Columns>
<asp:TemplateColumn HeaderText="Hotel Type">
<ItemTemplate>
<aspropDownList id="ddlhtype" runat="server" Font-Size="9px"
Font-Names="Verdana" Width="100px" AutoPostBack="true" >
<asp:ListItem Value="Hotel Type">Hotel Type</asp:ListItem>
</aspropDownList>
</ItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Hotel name">
<ItemTemplate>
<aspropDownList id="ddlhname" runat="server" Font-Size="9px"
Font-Names="Verdana" Width="100px"></aspropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</aspataGrid>

my code behind for the grid goes like this
Private Sub Datagrid2_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles Datagrid2.ItemCreated

If Not e.Item.FindControl("ddlhtype") Is Nothing Then
AddHandler CType(e.Item.FindControl("ddlhtype"),
DropDownList).SelectedIndexChanged, AddressOf GetHotelNames
End If

End Sub

the handler definition goes like this



Public Sub GetHotelNames(ByVal sender As Object, ByVal e As EventArgs)
Try
Dim quotemgr As New QuotationManager
Dim objcitystop As New CitystopServicesBE
objcitystop.ServiceCode = "CITYSTOP"
objcitystop.detailcode = "HTNM"
 
If Not CType(Datagrid2.FindControl("ddlhtype"), DropDownList) Is
Nothing Then
Dim strname As String
strname = CType(sender, DropDownList).SelectedValue.ToString()
objcitystop.Filter = strname
 
Dim col As New Collection
If Not CType(e.Item.FindControl("ddlhtype"),
DropDownList) Is Nothing Then
 
col = quotemgr.getcitystopdetails(objcitystop)
Dim objcity As CitystopServicesBE
For Each objcity In col
Dim strcode As New ListItem
strcode.Text = objcity.desc
strcode.Value = objcity.serviceid
Response.Write("before ddlname <br>")
 
If Not CType(Datagrid2.FindControl("ddlhname"),
DropDownList) Is Nothing Then
CType(Datagrid2.FindControl("ddlhname"),
DropDownList).Items.Add(strcode)
End If
Next
End If
 
 
 
Catch ex As Exception
Response.Write(ex.ToString)
End Try

Open in new window

0
vs1784Commented:
If you are using ASP.NET 2.0 you can use Ajax Control Toolkit.

It has cascading drop down control which can do exactly the same work for you, please check below link for example

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/CascadingDropDown/CascadingDropDown.aspx

Thanks
0
tracy_pAuthor Commented:
Thanks oleggold and vs1784.
i would i to use cascading dropdown control of ajax.
i have seen the weblink .i have 2 doubts.
can i use data in database table for populating instead of writing everything in xml file(as i have abt 70 items).
is it mandatory to write webservice?
thank you.
0
vs1784Commented:
It is not necessary to write web service. You can use page method instead which can be written on same page.

You can use database as well, below is the link for database binding.

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Walkthrough/CCDWithDB.aspx

Hope it helps
Thanks
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.