 |
| General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category.
** PLEASE BE SPECIFIC WITH YOUR QUESTION **
When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

December 19th, 2004, 10:42 PM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Dropdownlist Database Connection
I need helps.
Consider in a page i have two dropdown list. First dropdownlist displays DESCRIPTION and depending upon the selection of DESCRIPTION in first dropdownlist, i need to display DESCRIPTION SUMMARY in second dropdownlist. All of the data i get from SQL database.
First Dropdownlist SQL connection ( Success )-->
Const strSQL As String = "sp_GParam 'SELECT', '45', '', '', '', '', '', ''"
Second Dropdownlist ( Failed )-->
Dim SQLstr As String = "sp_GParam 'SELECT', '" & "ddlMainCat" & "', '', '', '', '', '', ''"
In the second dropdownlist, i want to populate the data by refer in first dropdownlist.
i want to use this method-->
After selecting a value from the DESCRIPTION dropdownlist. i can do a postback and get the data for DESCRIPTION SUMMARY and bind it to the other dropdown. This method involves a page refresh. All the controls in the page have to be refreshed and whatever data entered has to be retained.user has to wait till the page loads for entering other data in the page.
Can i discuss about all of it with anybody. I need to be more experiences in asp.net because i'm really beginner for it.
Thanks A Lot..
Syed
|
|

December 19th, 2004, 11:40 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
The .NET programming model is built around postbacks. If you want to build a page that doesn't use postbacks, you have to write a lot of client-side script to handle the changing data when the user changes the selected option in the dropdown list. There is no built in capability to do this in .NET.
|
|

December 20th, 2004, 04:39 AM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for the reply..
I really dont understand what do you mean by no built in capability to do this in .NET. Actually i use a postback to get my Second dropdownlist population but i think there is something wrong with my code or my coding technics. Take a look of my code-->
Const strSQL As String = "sp_GParam 'SELECT', '45', '', '', '', '', '', ''"
This is for my fisrt dropdownlist. I call from my SQL Server 2000 Stored Procedure and it's success. The value '45' inside the database are refer to-->
GroupID ItemID Description
45 46 Where To Stay
45 47 Where To Eat
45 48 What To Do
45 49 Getting Around
45 50 Popular Destination
45 52 Quick Info
45 53 Map
45 51 MainPage
Everything(DESCRIPTION) inside my first dropdownlist are successfuly populate.
in my second dropdownlist-->
Dim SQLstr As String = "sp_GParam 'SELECT', '" & "ddlMainCat" & "', '', '', '', '', '', ''"
For my second dropdownlist, i refer the value from my first dropdownlist. Let say i choose Getting Around from my fisrt dropdownlist. Its will become-->
GroupID ItemID Description
49 05 LRT
49 01 By Air
49 02 By Railway
49 03 Road
49 04 Monorail
49 06 By Sea
So, if i choose Getting Around description, my Second Dropdownlist should populate all value inside the DESCRIPTION.
Do you mind if you give me your comment, Please. I'm really confuse and lost focus right now.
Syed
|
|

December 21st, 2004, 07:38 AM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Please anybody, give me advice and help me to find the solution because all my task depends on second dropdownlist.
Syed
|
|

December 21st, 2004, 04:44 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
The problem is how you are constructing your SQL statement...
What you originally have:
SQLstr = "sp_GParam 'SELECT', '" & "ddlMainCat" & "', '', '', '', '', '', ''"
will result in this:
sp_GParam 'SELECT', 'ddlMainCat', '', '', '', '', '', ''"
which SQL will not understand because it will look for a value of 'ddlMainCat'.
What you want is this:
SQLstr = "sp_GParam 'SELECT', '" & ddlMainCat.SelectValue & "', '', '', '', '', '', ''"
|
|

December 21st, 2004, 09:54 PM
|
|
Authorized User
|
|
Join Date: Mar 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Yeah, as what planoie is saying you must not placing (") mark in front of your webcontrol id. the system will assume that you're looking for text ddlMainCat in your DB. So, second ddl shall declare as this:
Dim SQLstr As String = "sp_GParam 'SELECT', '" & ddlMainCat.selectedvalue & "', '', '', '', '', '', ''"
and please make sure your first ddl (that is ddlMainCat) has AutoPostBack that is set as true (in your HTML code).
Besides, I suggest that you call out your second ddl in between this codes in your .aspx. vb file.
Private Sub drpBatchUsing_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drpBatchUsing.SelectedIndexChanged
.
.
.
Dim SQLstr As String = "sp_GParam 'SELECT', '" & ddlMainCat.selectedvalue & "', '', '', '', '', '', ''"
.
.
End Sub
|
|

December 22nd, 2004, 11:01 PM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks everybody. I will try it first and hope its success. I will tell you if i'm success or not. Thanks a lot.
Syed
|
|
 |