473,320 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Dropdownlist - relations - asp.net

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


Nov 18 '05 #1
1 1925
are you getting any errors with this code?

Av.
"Ravi" <an*******@discussions.microsoft.com> wrote in message
news:60**********************************@microsof t.com...
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


Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bose | last post by:
Hi I have to make export of SQL Server Database to MS Access and I have done it with the tables but now I need to transfer(export) the relations, keys and indexes. Can any1 tell me how to read...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
1
by: Jef De Rycke | last post by:
Hi access group, I have written code to create relations between tables according to a corresponding relations information table. At first I thought my code was not working properly because...
1
by: Phill | last post by:
How do I add a dropdown list that contains two values, Option 1 and Option 2, in my datagrid and have this be databound. Thanks for your help.
1
by: Ravi | last post by:
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...
1
by: Randy Fraser | last post by:
How do I create a relationship on muliple columns in an untyped dataset. Why does this not work. da.Fill(ds) ds.Tables(0).TableName = "DesignSummary" ds.Tables(1).TableName = "FormulaSummary"...
2
by: Joe | last post by:
Hi I have a dataset with 3 tables and 2 relations Is there a way to when I am at 1 row to tell if there is a relation on that row ??? I have the code hardcoded but try to make it work if the #...
2
by: Joe | last post by:
Hi I am going to receive a dataset downstream and I will not know the the fields number of field relations number of relations So I have to be flexible to take unknown data and be able to...
5
by: G .Net | last post by:
Hi I'm hoping that somebody can help me with a fairly puzzling problem. I've created some DataTables which have relations between them e.g. one to many. In the application, I want to remove...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.