This is a migrated thread and some comments may be shown as answers.

How to pass server side values to sqldatasource?

1 Answer 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shanmug
Top achievements
Rank 1
Shanmug asked on 22 Sep 2008, 06:09 PM
Hi,

I'm using the SqlDataSource and Select Command with Parameters in the .aspx itself. I need to pass one of my Session and Query String values as the parameter value in the WHERE Clause of the Select statement in the Select Command. How can I pass the server side values (Session and Query String) in the SqlDataSource parameters?

1 Answer, 1 is accepted

Sort by
0
Priya
Top achievements
Rank 1
answered on 22 Sep 2008, 08:44 PM

Hi,

I need the value of  OrganizerID from the session. Right now I am passing  the Defaultvalue. The following is the snippet of the code.


<

asp:SqlDataSource ID="SqlDataSourceTest" runat="server" ConnectionString="<%$ ConnectionStrings:????????????ConnectionString %>"

SelectCommand
="SELECT E.OrganizerID, E.ID, E.LocationName, E.LocationAddress1, E.StartDate, E.EndDate, E.Details FROM dbo.tableName1 E INNER JOIN dbo.TableName2 O ON E.OrganizerID = O.ID WHERE E.OrganizerID=@OrganizerID"

OldValuesParameterFormatString
="original_{0}" ConflictDetection="CompareAllValues">

<
SelectParameters>
<asp:Parameter Name="OrganizerID" Type="Int32" DefaultValue="2000" />
</
SelectParameters>
</asp:SqlDataSource>

Any help would be highly appreciated. Thanks!!!!!!!!

Tags
Grid
Asked by
Shanmug
Top achievements
Rank 1
Answers by
Priya
Top achievements
Rank 1
Share this question
or