feeding a seesion/parameter value to Gridview

Discussion in 'ASP .Net Datagrid Control' started by staffan, Dec 7, 2006.

  1. staffan

    staffan Guest


    I am quite new to asp.net and before in old asp I used Session variables
    with <% %> to have dynamic parametrars in a SQL Stmt for example. But the
    serverside tag don´t accept <% %>. So what should a use? Is there serverside
    sessions and how do I use them or is there a simple method to use?



    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
    ConnectionStrings:s11243291ConnectionString %>"

    SelectCommand="SELECT TOP 100 PERCENT dbo.t_Choice.timeofchoice,
    t_Action.Actionname, dbo.t_Logg_call.infobox, dbo.t_Choice.choice,
    dbo.t_Logg_call.aNumber FROM dbo.t_Choice INNER JOIN dbo.t_Logg_call ON
    dbo.t_Choice.FK_CallID = dbo.t_Logg_call.CallID LEFT OUTER JOIN t_Action ON
    dbo.t_Choice.choice = t_Action.choiceCondition WHERE
    (dbo.t_Logg_call.FK_Customer = 1) AND (t_Action.FK_Customer = 1) AND
    (t_Action.NoAction = 0) ORDER BY dbo.t_Choice.timeofchoice DESC">

    staffan, Dec 7, 2006
    1. Advertisements

  2. staffan

    Phil H Guest

    Hi Steffan

    An SqlDataSource component can be configured with parameters that draw
    their values from Session Variables using the "Configure Datasource"
    wizard in VS 2005 or Visual web developer Express edition (the latter
    being totally free of charge from Microsoft).

    Alternatively, if you want to work directly in source code, then you
    need to add Parameter tags like the following example:

    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConnectionString="<%$ ConnectionStrings:MCCConnectionString %>"
    SelectCommand="SELECT STAFF_ID, Title, Forename, Surname,
    email, School_initials FROM Staff WHERE (LeavingDate IS NULL) AND
    (Surname = @surname) ORDER BY Surname, Forename">

    <!-- add parameters using the syntax of this example -->

    <asp:SessionParameter Name="surname"
    SessionField="sname" />


    The 'SessionField' attribute names the session variable to use.
    Phil H, Dec 20, 2006
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.