Good evening friends,
I have added a Drop Down List box control to my web form. I am using the
web.config connection string to access my SQL Server 2000 db. Inside that
db I have a table named Provinces.
The table contains 3 fields :
LanguageID
ProvinceID
Province
I have also added a SqlDataSource object and configured it to retrieve
Provinces based on my parameter named @languageID
<asp:DropDownLi st ID="ddlProvince " runat="server"
DataSourceID="P rovSqlDataSourc e"
DataTextField=" province" DataValueField= "province" Width="196px">
</asp:DropDownLis t></td>
<asp:SqlDataSou rce ID="ProvSqlData Source" runat="server"
CacheExpiration Policy="Sliding "
ConnectionStrin g="<%$ ConnectionStrin gs:MyConnection String %>"
SelectCommand=" SELECT DISTINCT [province] FROM [provinces] WHERE
([languageID] = @languageID ) ORDER BY [province]">
</asp:SqlDataSour ce>
My problem is how I may gain access to the @languageID parameter. I feel
kinda stoopid, as this may be an easy solution.
It has to change either "1" for English and "2" for French,,,
Depending on the language chosen for the web form page. So I use this code
to retrieve the language chosen by the user.
<%
Dim languageSuffix, altlang, lang As String
Dim langID As Int32
lang = Request.QuerySt ring("lang")
If Request.QuerySt ring("lang") = "" Then
lang = "en"
End If
'Response.Write ("<br />The Lang is--" & lang)
If (lang = "fr") Then
langID = 2
altlang = "fr"
Else ' lang = "en"
langID = 1
altlang = "en"
End If
Response.Write( ("<br />The LangID is--" & langID))
%>
But I cannot for the life of me figure out how to gain access to the
@languageID and add 1 if English or 2 if French.
Any ideas, code examples or urls would be greatly appreciated,
Thanks in advance
~Brad 2 2466
Brad,
You can manually update your parameters and select the data through code via:
Me.ProvSqlDataS ource.SelectPar ameters("langua geID").DefaultV alue = langID
Me.ProvSqlDataS ource.Select(Da taSourceSelectA rguments.Empty)
Also, try handling the querystring logic in your page_load event.
See the code below.
Hope this helps,
Jason Vermillion
<asp:SqlDataSou rce ID="ProvSqlData Source" runat="server"
SelectCommand=" SELECT DISTINCT [province] FROM [provinces] WHERE
([languageID] = @languageID ) ORDER BY [province]">
<SelectParamete rs>
<asp:Paramete r Name="languageI D" />
</SelectParameter s>
</asp:SqlDataSour ce>
Then in your page_load...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s)
Handles Me.Load
Dim altlang As String
Dim lang As String
Dim langID As Int32
lang = Request.QuerySt ring("lang")
If Request.QuerySt ring("lang") = "" Then
lang = "en"
End If
'Response.Write ("<br />The Lang is--" & lang)
If (lang = "fr") Then
langID = 2
altlang = "fr"
Else ' lang = "en"
langID = 1
altlang = "en"
End If
Me.ProvSqlDataS ource.SelectPar ameters("langua geID").DefaultV alue = langID
Me.ProvSqlDataS ource.Select(Da taSourceSelectA rguments.Empty)
End Sub
"Brad Isaacs" wrote:
Good evening friends,
I have added a Drop Down List box control to my web form. I am using the
web.config connection string to access my SQL Server 2000 db. Inside that
db I have a table named Provinces.
The table contains 3 fields :
LanguageID
ProvinceID
Province
I have also added a SqlDataSource object and configured it to retrieve
Provinces based on my parameter named @languageID
<asp:DropDownLi st ID="ddlProvince " runat="server"
DataSourceID="P rovSqlDataSourc e"
DataTextField=" province" DataValueField= "province" Width="196px">
</asp:DropDownLis t></td>
<asp:SqlDataSou rce ID="ProvSqlData Source" runat="server"
CacheExpiration Policy="Sliding "
ConnectionStrin g="<%$ ConnectionStrin gs:MyConnection String %>"
SelectCommand=" SELECT DISTINCT [province] FROM [provinces] WHERE
([languageID] = @languageID ) ORDER BY [province]">
</asp:SqlDataSour ce>
My problem is how I may gain access to the @languageID parameter. I feel
kinda stoopid, as this may be an easy solution.
It has to change either "1" for English and "2" for French,,,
Depending on the language chosen for the web form page. So I use this code
to retrieve the language chosen by the user.
<%
Dim languageSuffix, altlang, lang As String
Dim langID As Int32
lang = Request.QuerySt ring("lang")
If Request.QuerySt ring("lang") = "" Then
lang = "en"
End If
'Response.Write ("<br />The Lang is--" & lang)
If (lang = "fr") Then
langID = 2
altlang = "fr"
Else ' lang = "en"
langID = 1
altlang = "en"
End If
Response.Write( ("<br />The LangID is--" & langID))
%>
But I cannot for the life of me figure out how to gain access to the
@languageID and add 1 if English or 2 if French.
Any ideas, code examples or urls would be greatly appreciated,
Thanks in advance
~Brad
Jason,
Thanks for your input.
I was able to use the QueryString parameter. My problem was that I was not
sending the langID=1 or langID=2 when the user had chosen a language for the
page. I needed to PASS the value. Once I passed the value, all I had to do
was add the QueryString parameter and it all worked.
Thanks again for your input.
~Brad
"Jason Vermillion" <Ja************ *@discussions.m icrosoft.comwro te in
message news:3E******** *************** ***********@mic rosoft.com...
Brad,
You can manually update your parameters and select the data through code
via:
Me.ProvSqlDataS ource.SelectPar ameters("langua geID").DefaultV alue = langID
Me.ProvSqlDataS ource.Select(Da taSourceSelectA rguments.Empty)
Also, try handling the querystring logic in your page_load event.
See the code below.
Hope this helps,
Jason Vermillion
<asp:SqlDataSou rce ID="ProvSqlData Source" runat="server"
SelectCommand=" SELECT DISTINCT [province] FROM [provinces] WHERE
([languageID] = @languageID ) ORDER BY [province]">
<SelectParamete rs>
<asp:Paramete r Name="languageI D" />
</SelectParameter s>
</asp:SqlDataSour ce>
Then in your page_load...
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArg s)
Handles Me.Load
Dim altlang As String
Dim lang As String
Dim langID As Int32
lang = Request.QuerySt ring("lang")
If Request.QuerySt ring("lang") = "" Then
lang = "en"
End If
'Response.Write ("<br />The Lang is--" & lang)
If (lang = "fr") Then
langID = 2
altlang = "fr"
Else ' lang = "en"
langID = 1
altlang = "en"
End If
Me.ProvSqlDataS ource.SelectPar ameters("langua geID").DefaultV alue =
langID
Me.ProvSqlDataS ource.Select(Da taSourceSelectA rguments.Empty)
End Sub
"Brad Isaacs" wrote:
>Good evening friends,
I have added a Drop Down List box control to my web form. I am using the web.config connection string to access my SQL Server 2000 db. Inside that db I have a table named Provinces.
The table contains 3 fields :
LanguageID ProvinceID Province
I have also added a SqlDataSource object and configured it to retrieve Provinces based on my parameter named @languageID
<asp:DropDownL ist ID="ddlProvince " runat="server" DataSourceID=" ProvSqlDataSour ce"
DataTextField= "province" DataValueField= "province" Width="196px">
</asp:DropDownLis t></td>
<asp:SqlDataSo urce ID="ProvSqlData Source" runat="server" CacheExpiratio nPolicy="Slidin g"
ConnectionStri ng="<%$ ConnectionStrin gs:MyConnection String %>"
SelectCommand= "SELECT DISTINCT [province] FROM [provinces] WHERE ([languageID] = @languageID ) ORDER BY [province]">
</asp:SqlDataSour ce> My problem is how I may gain access to the @languageID parameter. I feel kinda stoopid, as this may be an easy solution.
It has to change either "1" for English and "2" for French,,,
Depending on the language chosen for the web form page. So I use this code to retrieve the language chosen by the user.
<%
Dim languageSuffix, altlang, lang As String
Dim langID As Int32 lang = Request.QuerySt ring("lang")
If Request.QuerySt ring("lang") = "" Then
lang = "en"
End If
'Response.Writ e("<br />The Lang is--" & lang)
If (lang = "fr") Then
langID = 2
altlang = "fr"
Else ' lang = "en"
langID = 1
altlang = "en"
End If
Response.Write (("<br />The LangID is--" & langID))
%>
But I cannot for the life of me figure out how to gain access to the @languageID and add 1 if English or 2 if French.
Any ideas, code examples or urls would be greatly appreciated,
Thanks in advance
~Brad This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Swetha |
last post by:
Hello
I have a DropDownList that I am populating using the following
SqlDataSource:
<asp:DropDownList ID="parentIDDropDownList" runat="server"
DataSourceID="SqlDataSource3" DataTextField="name"
DataValueField="ID"></asp:DropDownList><asp:SqlDataSource
ID="SqlDataSource3" runat="server" ConnectionString="<%$
ConnectionStrings:ConnectionString %>"
|
by: P. Yanzick |
last post by:
Hello,
I've been playing with master/detail views as well as editing in the
gridview, and I ran across a strange problem that I am not exactly sure
where to go to try to solve.
I have 2 tables, a table of cars (pretty basic, an ID, a description, and a
Color ID) and a table of colors (Color ID, and a color description). I've
added a gridview and a detailsview as I'm playing with both and how to get
editing features to work the way I...
|
by: Dabbler |
last post by:
I have a dropdownlist in a GridView ItemTemplate. I need to bind the ddl to
an SqlDataSource, then have a value from a boundfield in the row be passed as
the keyfield for select where clause. Im trying to load the ddl with a list
of dates from another table keyed on GridView row field that only apply to
this row.
Any suggestions would be appreciated.
|
by: K B |
last post by:
Hi,
I've tried this several ways but get the error that the control can't be
found.
I have a details view with a dropdownlist in the EditItemTemplate
populated and assigned the selected value in code.
I need to get the selected value when the record is saved. I've tried
using the following in the SqlDataSource updating event:
|
by: Jason Wilson |
last post by:
I have two dropdownlists that are bound to the same datasource and I
have a couple of questions:
1) Because they are bound to the same datasource, I am assuming that
they only make 1 round trip to the DB server -- is that correct?
2) On a user's click of a button, one of the actions in the button
OnClick event is to set the selectedindex of the 2nd DDL to that of the
1st. I get a runtime error here that says that the given index is...
| |
by: andy |
last post by:
Hi,
I have a form uses several dropdownlists to narrow a set of criteria.
( This is in turn used to control what is shown on a gridview. )
With each, the user selects an entry and then the next dropdownlist
uses that control's selected value to drive what it shows.
They're all set to autopostback.
Everything works fine except where one of the levels only has one
entry.
This seems to mess up the next level down and you see the wrong
|
by: gsauns |
last post by:
Hello,
I have an ASP.NET app with a DropDownList on the page, which is bound
to values from a table. I have a Repeater control on the page whose
displayed data is dependent on the DropDownList value selected by the
user. (The DataTextField is a Datetime concatenated with a string).
On the Page_Load event, if it's not a postback, I would like the
DropDownList to programmatically be set to the next occurring day in
the DropDownList (the...
|
by: lamolap |
last post by:
i have 1 gridview , a dropdownlist inside a gridview and a commandfield of (edit, update and cancel)
my gidview looks like this
Edit Surname Initials ParkingBay
CommandField Me Y dropdownlistvalue
CommandField You m dropdownlistvalue
i have 2 sqldatasource. the other one is for gridview and...
|
by: Brett |
last post by:
I have a DropDownList in an ASP.NET web form that is populated with items
from a lookup table by binding that DropDownList to a SqlDataSource.
However, the items in the lookup table can change over time. The problem is
that when an item has been removed from the lookup table, and a user wants
to retrieve a record that used the deleted item, the following error occurs:
'ddlAssignedTo' has a SelectedValue which is invalid because it...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |