Solved

How to pass String value From CS file to aspx file to get the query result ?

Posted on 2009-07-07
4
1,040 Views
Last Modified: 2012-05-07
Hello All,

I was developing a application in the intranet which will show Health, Payslip and other Security pages in this application. I used AJAX Tab Control in this application to get more flexible information to the users. I used Windows Authentication. So I get the user information using User.Identity.Name. Which is availble in our ASP.Net 2.0.

So I was getting the user information and storing that one in a string varible. I need to pass the this varialble to aspx application query string. Because I was writing the query string in aspx file.

How can I pass the Variable  from CS file to ASPX page Query String.

For example the below one is the query in the aspx page for getting Customer information from NorthWind Database. In that query I need to pass the variable, so that I can write WHERE condition in that one.

<asp:SqlDataSource ID="sqldsCustomers" runat="server" SelectCommand="select customerid, companyname, contactname, contacttitle, address, city from dbo.[customers]

So please guide me.

Thanks,
Rao.
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
Rahul Goel ITIL earned 250 total points
ID: 24801258
You can use Response.Redirect(URL + "?id=" + id.ToString());

and THEN

<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="..." ProviderName="System.Data.SqlClient"SelectCommand="SELECT [UserId], [LastUpdatedDate] FROM [vw_aspnet_Profiles] WHERE ([UserId] = @UserId)">
<SelectParameters>
<asp:QueryStringParameterDefaultValue="0"Name="UserId"QueryStringField="Id"Type="Object"/>
</SelectParameters>
</asp:SqlDataSource>

Open in new window

0
 
LVL 13

Author Comment

by:PillalamarriVenkateswaraRao
ID: 24801480
Thanks for the response.
How Can I call My concatenateUserNameMailId string value into the below "----------- "area
 <asp:SqlDataSource ID="HealthInformation" runat="server" ConnectionString="<%$ ConnectionStrings:TAMSConnection %>"
ProviderName="<%$ ConnectionStrings:TAMSConnection.ProviderName %>"
SelectCommand='SELECT "ID_NO", "GENERALNAME", "JOINDATE", "DEPT" FROM "TABLENAME" WHERE ("LEFTDATE" IS NULL) and "email"=------------------------ '>
In this I'm using Oracle Connection.
concatenateUserNameMailId is from CS File. So Suggest me what I need to do ?
Thanks
 
0
 
LVL 5

Assisted Solution

by:ashokpumca
ashokpumca earned 250 total points
ID: 24801718
Try this one.... Hope this helps...

<asp:SqlDataSource ID="HealthInformation" runat="server" ConnectionString="<%$ ConnectionStrings:TAMSConnection %>"
ProviderName="<%$ ConnectionStrings:TAMSConnection.ProviderName %>"
SelectCommand='SELECT "ID_NO", "GENERALNAME", "JOINDATE", "DEPT" FROM "TABLENAME" WHERE ("LEFTDATE" IS NULL) and "email"='<%#DataBinder.Eval(Container.DataItem,"concatenateUserNameMailId ")%>'>
0
 
LVL 13

Author Closing Comment

by:PillalamarriVenkateswaraRao
ID: 31600971
Thanks Guys.
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question