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 1 1424
If I understand you correctly, you're trying to do is fetch data from
the server to populate the second dropdown. So don't think Relations,
think WHERE clause in your SELECT statement. If you've already fetched
the data into another DataTable in the DataSet, then you can set the
relations.
--Mary
On Sun, 16 May 2004 21:16:02 -0700, "Ravi"
<an*******@discussions.microsoft.com> wrote: 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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: kamaumalone |
last post by:
I have a dropdownlist which lives inside of a repeater. The repeater
accepts user input via textboxes and the aforementioned dropdownlist.
The repeater accepts phone numbers and allows for an...
|
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...
|
by: PJ |
last post by:
I have several dropdownlist controls in a placeholder on my form. Certain
events will show this place holder and populate the values of the items
collection of the dropdownlist controls. A...
|
by: Joe Van Meer |
last post by:
Hi all,
I have a question regarding data relations within a data set. Say I have 3
tables named CLIENT, BOOKING and EMPLOYEE and I wanted to relate the first
two tables (CLIENT AND BOOKING)...
|
by: mg |
last post by:
I have a DataGrid (WebForm - C#) that has a template column that contains a dropdownlist named "DdlTest"
In DataGrid1_UpdateCommand, the lin
DropDownList ddlTest = (DropDownList)...
|
by: glenn |
last post by:
Hi folks,
I have a DropDownList in a DataGrid that is populated from records in a
database.
I want to add a value that might be a string such as "Select a Company" for
the first item since an...
|
by: shahDeveloper |
last post by:
i have created a number of combo boxes according to my need.no i want to save the changes when any one click update button,but here the control did not find by findcontrol function.
Dim i, j, totc...
|
by: kjewell23 |
last post by:
Hi. I have the code working just fine except all the data isn't coming up with the ds.relations code. Could you see what I'm doing wrong or what else I need to add. Code down below
Dim adapter As...
|
by: chathura86 |
last post by:
hi,
i have a table which has child rows in another table. Now i want to truncate this
table temporally, because i will re-enter those values in a short time with some changes. cannot use update...
|
by: MaryamSh |
last post by:
Create Dynamic Dropdownlist Controls and related event
--------------------------------------------------------------------------------
Hi,
I am creating a Dynamic Search in my application.
I...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |