Solved

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

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now