0

I have four database on same server, I am using SqlDataSource Control to bind grid view in my application.And I have implemented a drop-down base on its item selection connection string is saved in a session variable. but I don't know how to pass this session variable in connctionstring property of SqlDataSource Control

<asp:SqlDataSource ID="dsMyAlarm" runat="server" ConnectionString="<%$ ConnectionStrings:AlarmDirectorDTUConnectionString %>"  SelectCommand="AD_FetchAlarmSubscriptionsByUserID" SelectCommandType="StoredProcedure">
     <SelectParameters>
                <asp:SessionParameter DefaultValue="0" Name="ContactId" SessionField="CurrentUser" Type="Int32" />
      </SelectParameters>
 </asp:SqlDataSource>

In This property I want to pass a session variable

ConnectionString="<%$ ConnectionStrings:AlarmDirectorDTUConnectionString %>"

Is it possible? or can i achive this by other way please suggest me I am open for suggestion

1 Answer 1

1

You could bind the session variable in code behind page_load.

dsMyAlarm.connectionString=Session["constr"];

or refer to the document data binding expression.https://support.microsoft.com/en-in/kb/976112

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.