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

Discussion in 'ASP .Net' started by Radu, Feb 22, 2007.

  1. Radu

    Radu Guest

    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.
     
    Radu, Feb 22, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Random

    2.0 FilterParameters bug

    Random, Jun 7, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    539
    Juan T. Llibre
    Jun 7, 2005
  2. Replies:
    1
    Views:
    7,580
    Markus
    Aug 25, 2005
  3. Andre

    FilterParameters

    Andre, Jan 10, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    696
    Andre
    Jan 10, 2006
  4. Bruno Alexandre

    problem in FilterParameters

    Bruno Alexandre, Apr 5, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    2,204
  5. David
    Replies:
    0
    Views:
    686
    David
    Apr 19, 2006
Loading...

Share This Page