<FilterParameters>, please.... I'm stuck on this one !

R

Radu

Hi. On the first page of my website the user selects one document
which can be in either English or French. I store that choice in a
class, and I can extract it with:
CType(Session("UsersSessionClass"), UserSessionClass).SelLanguage

Later in my 'wizard' I have a page which contains this html:
__________________________________________________________________
<form id="frmStep4ConfigureDoYous" runat="server">

<%-- Store the language somewhere - it will be used for filtering the
SqlDataSource below --%>
<% Dim strScLang As String%>
<% strScLang = CType(Session("UsersSessionClass"),
UserSessionClass).SelLanguage%>
<% HyperLinkScorecardLanguage.Text = strScLang%>
<asp:HyperLink ID="HyperLinkScorecardLanguage" runat="server"></
asp:HyperLink>
<div>
__________________________________________________________________
(For some reason I could not assign the language directly to the text
property of the HyperLink).


I can see the language 'FR' or 'EN', depending on the choice on the
first page. So far so good.

In the same page, below, I have the HTML:
__________________________________________________________________
<asp:DropDownList ID="cboDoYou"
AppendDataBoundItems="True"
DataSourceID="DoYousSqlDataSource"
DataTextField="DoYou"
DataValueField="DoYou"
runat="server">
</asp:DropDownList>


<asp:SqlDataSource
ID="DoYousSqlDataSource"

SelectCommand="SELECT DISTINCT
Principles.[Principle ID] as PrincipleID,
DoYous.[DoYou Description] as DoYou,
DoYous.[DoYou Language] as ScorecardLanguage
FROM DoYous_BY_Principle_BY_ScType
INNER JOIN Principles
ON DoYous_BY_Principle_BY_ScType.[Principle ID] = Principles.
[Principle ID]
INNER JOIN DoYous
ON DoYous_BY_Principle_BY_ScType.[DoYou ID] = DoYous.[DoYou ID]"

EnableCaching="True"
CacheDuration="60"
FilterExpression="PrincipleID = {0} AND ScorecardLanguage = '{1}'"
ConnectionString="Data Source='...."
RunAt="server">

<FilterParameters>
<asp:ControlParameter ControlID="HyperLinkPrincipleID"
PropertyName="Text" />
<asp:ControlParameter ControlID="HyperLinkScorecardLanguage"
PropertyName="Text" />
</FilterParameters>
</asp:SqlDataSource>
__________________________________________________________________
Question 1. Although I can clearly see the language in the control
'HyperLinkScorecardLanguage' at the beginning of the page, I can't
reference it in my FilterParameters, meaning that it does not throw an
error, but it doesn't filter properly either - it populates cboDoYou
with the values from the 'DoYou' column of table DoYous, for the
correct PrincipleID (the one on the current row in the repeater), but
for BOTH EN and FR....

However, if I hardcode the FilterExpression to
FilterExpression="PrincipleID = {0} AND ScorecardLanguage = 'EN'"
or
FilterExpression="PrincipleID = {0} AND ScorecardLanguage = 'FR'"
it all works great !


If in break mode in the code-behind page I interrogate
HyperLinkScorecardLanguage.text, it returns an empty string (although
I can see 'EN' in the HyperLinkScorecardLanguage control !), so
therefore I guess I'm not referencing the HyperLinkScorecardLanguage
control properly in my line
<asp:ControlParameter ControlID="HyperLinkScorecardLanguage"
PropertyName="Text" />

What is the correct syntax, please ? Where is my problem ?



Question 2. Instead of hardcoding
ConnectionString="Data Source='blah-blah-blah...."
I would like to use the setting from WebConfig
<appSettings>
<add key="ConnectionString" value="Data Source=..."/>
by using
System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
as in:
ConnectionString='<%=
System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
%>'
but this does not work ! How can I specify the connection string in
this case ?

Thanks a lot !
Alex.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top