Solved

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

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Suggested Solutions

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

736 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