Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Dropdownlist - relations - asp.net

Reply
Thread Tools

Dropdownlist - relations - asp.net

 
 
=?Utf-8?B?UmF2aQ==?=
Guest
Posts: n/a
 
      05-17-2004
I am trying to represent master-detail records from a database
The general logic will be populating the first dropdownlist with the master records and on change of the first dropdownlis
getting the selectedindex and querying the database and populating the childrecords in the second dropdownlist

But my question is how the same can be acheieved by using "Relations"

The following code fragment i tried, but i have no idea how to proceed

Thanks in advanc
Ravichandra

Dim myconn As Strin
Dim oledataadapt As New OleDbDataAdapte
Dim oledataadapt1 As New OleDbDataAdapte
Dim ds As New DataSe
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
'Put user code to initialize the page her

myconn = "Provider=MSDAORA;User ID=x;Password=x;Data Source=xxx;
oledataadapt = New OleDbDataAdapter("Select Organization_id from bengine.cb_organization", myconn
oledataadapt.Fill(ds, "Sector"

oledataadapt1 = New OleDbDataAdapter("Select Superbu_id, organization_id from bengine.cb_super_businessunit", myconn
oledataadapt1.Fill(ds, "SBU"
ds.Relations.Add("Sec_sbu", ds.Tables("Sector").Columns("Organization_id"),
ds.Tables("SBU").Columns("Organization_id")
If Not IsPostBack The
DropDownList1.DataSource = ds.Tables(0).DefaultVie
DropDownList2.DataSource = ds.Tables(1).DefaultVie
DropDownList1.DataMember = "Organization_id
DropDownList2.DataMember = "superbu_id
DropDownList1.DataTextField = "Organization_id
DropDownList1.DataValueField = "Organization_id
DropDownList2.DataTextField = "superbu_id
DropDownList2.DataValueField = "superbu_id
DropDownList1.DataBind(
DropDownList2.DataBind(
End I
End Su

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChange
Dim i As Intege
i = DropDownList1.SelectedInde
DropDownList2.DataSource = ds.Tables(0).Rows(i).GetChildRows("Sec_sbu"
DropDownList2.DataTextField = "superbu_id
DropDownList2.DataValueField = "superbu_id
DropDownList1.DataBind(
DropDownList2.DataBind(
End Su






 
Reply With Quote
 
 
 
 
avnrao
Guest
Posts: n/a
 
      05-17-2004
are you getting any errors with this code?

Av.
"Ravi" <> wrote in message
news:60F0574D-C87C-42CF-8572-...
>I am trying to represent master-detail records from a database.
> The general logic will be populating the first dropdownlist with the
> master records and on change of the first dropdownlist
> getting the selectedindex and querying the database and populating the
> childrecords in the second dropdownlist.
>
> But my question is how the same can be acheieved by using "Relations"?
>
> The following code fragment i tried, but i have no idea how to proceed.
>
> Thanks in advance
> Ravichandran
>
> Dim myconn As String
> Dim oledataadapt As New OleDbDataAdapter
> Dim oledataadapt1 As New OleDbDataAdapter
> Dim ds As New DataSet
> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> 'Put user code to initialize the page here
>
> myconn = "Provider=MSDAORA;User ID=x;Password=x;Data Source=xxx;"
> oledataadapt = New OleDbDataAdapter("Select Organization_id from
> bengine.cb_organization", myconn)
> oledataadapt.Fill(ds, "Sector")
>
> oledataadapt1 = New OleDbDataAdapter("Select Superbu_id,
> organization_id from bengine.cb_super_businessunit", myconn)
> oledataadapt1.Fill(ds, "SBU")
> ds.Relations.Add("Sec_sbu",
> ds.Tables("Sector").Columns("Organization_id"), _
> ds.Tables("SBU").Columns("Organization_id"))
> If Not IsPostBack Then
> DropDownList1.DataSource = ds.Tables(0).DefaultView
> DropDownList2.DataSource = ds.Tables(1).DefaultView
> DropDownList1.DataMember = "Organization_id"
> DropDownList2.DataMember = "superbu_id"
> DropDownList1.DataTextField = "Organization_id"
> DropDownList1.DataValueField = "Organization_id"
> DropDownList2.DataTextField = "superbu_id"
> DropDownList2.DataValueField = "superbu_id"
> DropDownList1.DataBind()
> DropDownList2.DataBind()
> End If
> End Sub
>
> Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
> ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
> Dim i As Integer
> i = DropDownList1.SelectedIndex
> DropDownList2.DataSource =
> ds.Tables(0).Rows(i).GetChildRows("Sec_sbu")
> DropDownList2.DataTextField = "superbu_id"
> DropDownList2.DataValueField = "superbu_id"
> DropDownList1.DataBind()
> DropDownList2.DataBind()
> End Sub
>
>
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dropdownlist - relations-asp.net-how to? =?Utf-8?B?UmF2aQ==?= ASP .Net 1 05-17-2004 09:43 PM
Dropdownlist - how to use relations Ravi ASP .Net Web Controls 0 05-14-2004 06:26 AM
data relations Joe Van Meer ASP .Net 4 05-05-2004 06:57 PM
data relations and datasets inquiry Joe Van Meer ASP .Net 0 05-05-2004 01:30 PM
Can't decide between Relations::Family and Class::DBI Nicolas STAMPF Perl 0 05-04-2004 12:16 PM



Advertisments