Solved

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 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