feeding a seesion/parameter value to Gridview

S

staffan

Hi

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?

Thanks!!!!

/Staffan



"
<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">

</asp:SqlDataSource>"
 
P

Phil H

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 -->

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


</asp:SqlDataSource>

The 'SessionField' attribute names the session variable to use.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top