473,399 Members | 3,038 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,399 software developers and data experts.

dynamic dropdown lists

So I've got three dropdowns in a datagrid footer (to add records). I need
them to cascade, in the first one I have three choices, in the second one I
have anywhere from 3 to 10 choices, depending on what is selected in the
first one, etc, etc.

Whats happening is that when the auto-postback occurs, it fires the event
for the dropdownlist change, which calls the Getxxx routines that update the
dropdownlist's datasource to the new datatable (from a query). Then it turns
around and fires the Getxxxx routines again, with the default values when
the page is being created. I cant figure out a way to solve this
double-execution thats going on.... Any help? Thanks in advance. Code is
below...

-Anthony

PS: I've verified that my queries do return the correct data, I've steped
through the code and verified that. Also, when creating the dropdownlists in
the footer of the datagrid, I cant seem to access them from the code-behind
file (even though they are there in the aspx file, the code behind file has
no variable declaration for them, and attempts to put them in dont work),
which is why i have to use the datagrid item to access the footer and then
..FindControl them.

I've got my dropdown lists in the ASPX file as follows...

[...]

<asp:DropDownList id="ddlTask" runat="server" AutoPostBack="True"
DataValueField="TASK" DataTextField="TASK"
DataSource='<%# GetTasks() %>'
OnSelectedIndexChanged="ddlTask_SelectedIndexChang e"/>

[...]

<asp:DropDownList id="ddlDrwgtype" runat="server" AutoPostBack="True"
DataValueField="DRWGTYPE" DataTextField="DRWGTYPE"
DataSource='<%# GetDrwgType("") %>'
OnSelectedIndexChanged="ddlDrwgtype_SelectedIndexC hange"/>

[...]

<asp:DropDownList id="ddlStep" runat="server"
DataValueField="STEP" DataTextField="STEP"
DataSource='<%# GetStep("","") %>' />

[...]

In the code-behind file, the routines are as follows...
Protected WithEvents newtask As OleDb.OleDbDataAdapter
Protected WithEvents newdrwgtype As OleDb.OleDbDataAdapter
Protected WithEvents newstep As OleDb.OleDbDataAdapter

[...]

Public Function GetTasks() As DataTable
newtask.Fill(dstask, "TASKLUT")
Return dstask.Tables("TASKLUT")
End Function

Public Function GetDrwgType(ByVal task As String) As DataTable
If task = "" Then task = "FACILITIES"
newdrwgtype.SelectCommand.Parameters("TASK").Value = task
If dstask.Tables.Contains("DRWGTYPELUT") Then
dstask.Tables.Remove("DRWGTYPELUT")
End If
newdrwgtype.Fill(dstask, "DRWGTYPELUT")
Return dstask.Tables("DRWGTYPELUT")
End Function

Public Function GetStep(ByVal task As String, ByVal drwgtype As String)
As DataTable
If task = "" Then task = "FACILITIES"
If drwgtype = "" Then drwgtype = "600MAP"
If dstask.Tables.Contains("STEPLUT") Then
dstask.Tables.Remove("STEPLUT")
End If
newstep.SelectCommand.Parameters("TASK").Value = task
newstep.SelectCommand.Parameters("DRWGTYPE").Value = drwgtype
newstep.Fill(dstask, "STEPLUT")
Return dstask.Tables("STEPLUT")
End Function

Public Sub ddlTask_SelectedIndexChange(ByVal sender As Object, ByVal e
As EventArgs)
Dim ddltask As DropDownList = sender
Dim dgFooter As DataGridItem = ddltask.Parent.Parent
Dim ddlDrwgtype As DropDownList =
dgFooter.FindControl("ddldrwgtype")
Dim task As String = ddltask.SelectedValue
ddlDrwgtype.DataSource = GetDrwgType(task)
ddlDrwgtype.DataBind()
End Sub

Public Sub ddlDrwgtype_SelectedIndexChange(ByVal sender As Object, ByVal
e As EventArgs)
Dim ddldrwgtype As DropDownList = sender
Dim dgFooter As DataGridItem = ddldrwgtype.Parent.Parent
Dim ddltask As DropDownList = dgFooter.FindControl("ddltask")
Dim ddlstep As DropDownList = dgFooter.FindControl("ddlstep")

Dim task As String = ddltask.SelectedValue
Dim drwgtype As String = ddldrwgtype.SelectedValue

ddlstep.DataSource = GetStep(task, drwgtype)
ddlstep.DataBind()
End Sub
Nov 19 '05 #1
0 1119

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

Similar topics

0
by: Toonman | last post by:
I have a webpage with a <form> consisting of a large table grid of dropdown lists used to make changes in a database. Some of these dropdown lists have the same value. I'm trying to make it so...
1
by: Dmitri Shvetsov | last post by:
Hi All, Is it possible at all, and if yes, then how? Or it's very/extremely hard to do that? Maybe somebody knows...) I'm writing a Web App using VS2003/C#/MSSQL. I'm currently having about...
0
by: Henke | last post by:
Hi, I have done some research about my problem I have when using the "back button" in IE to go back to a page with two dropdown lists. The both dropdown lists are populated with data. The...
6
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
3
by: simon | last post by:
hello, i have a form where there are multiple dropdown lists that will all be populated from the same initial data query. i have a vb class defined to make the stored proc call and that returns a...
11
by: simon | last post by:
hello, I have a form that has 10 dropdown lists in one section each of the dropdowns contain the same data what i'm looking to do is that when a user selects a value from one dropdown, change...
4
by: Gregory Gadow | last post by:
If there is a more appropriate forum, please let me know and I will post there. Our field reps can go on to our website and select from several sets of data to create the address we then provide...
1
by: vpulugurta | last post by:
I’m working on a page that has multiple dropdownlists. When we direct a user to this page, some number DDL’s are displayed to the user depending on their profiles. The data for all these DDL’s...
3
by: John | last post by:
I have two dropdown lists that I have bound to a datatable and set the DataTextField and DataValueField for. Both lists show the values I expect from the database. However, when I need to access...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.