Click here to Skip to main content
15,894,896 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How can we call connection string in Sqldatasource from class instead of writing directly ?

What I have tried:

ASP.NET
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [Course_details]"></asp:SqlDataSource>
Posted
Updated 31-Aug-16 5:37am
v2
Comments
ZurdoDev 29-Aug-16 13:45pm    
SqlDataSource1.ConnectionString=whatever you want. Where are you stuck?
Halit Yurttaş 29-Aug-16 16:09pm    
Where is your connection string? its in the web.config, is it?
Member 11165894 30-Aug-16 1:21am    
I am calling connection string from class

1 solution

just do like
C#
SqlDataSource1.ConnectionString=ObjClass.StringConnectionObj;
on the web form load.
if its a static class then
C#
SqlDataSource1.ConnectionString=Class1.StringConnectionObj;

and you are good to go.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900