Solved

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

Posted on 2009-07-07
4
1,035 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
  • 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 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