Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL-Server
Hello Friends,
 
am working on asp.net, i have two pages in my project.
 
first page is login page
second page is retrieve data from database based on login dropdown selection.
 
In first page(Login Page) I have Dropdownlist(departmentList) and Textbox(password)
and a login button.
 
User will select the department from dropdown and then next he enters the password, and clicks on login button.
When User clicks on login button, In second page I have 3 textboxes to retrieve data from database according to dropdownlist.
 
In database I have Stored data with in these fields,
 
Dept_code,Password,Salary,TelephoneNo,ManagerName.(TableName DeptInfo)
 
Dept_code - IT (This will display in dropdownlist(loginPage) )
Password - This is used for login
Salary - this should display in textbox after login( it must retrieve from DB)
Telephone - this should also display in textbox after login ( it must retrieve from DB)
Manager Name - this should also display in textbox after login ( it must retrieve from DB)
 

Please can you help me , how to solve this.
 
already i have completed login page , and now am in second page with textboxes.
 
Please help.
 
THANKS.
Posted 28-Apr-13 0:52am
Comments
ThePhantomUpvoter at 28-Apr-13 7:23am
   
"how to solve this"... the exact same way the you have already been told.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

you can do the following:
 
on First Page(Login) :
 
you need to put your dropdown selectedValue in session to move it to the next page.
 
after successfull login: On second page you first need to get that values from session. and Then you the following...
<pre lang="cs">
string sessValue = Conver.ToString(Session["youSessionName"]);
youConectionName.Open();
SqlCommand cmd = new SqlCommand("Select * from DeptInfo where DeptCode='" + sessValue + "'", youConectionName);
 
SqlDataReader dr = cmd.ExecuteReader();
        if (dr.HasRows)
        {
            Salary.Text  = rd["Salary"].ToString();
            Telephone.Text =rd["TelephoneNo"].ToString();
            Manager Name.Text=rd["ManagerName"].ToString();
        }
        else
        {
            //Code will reach here if no records found.
        }
</pre>
 

you can call this on page load or on button click as you want...
 
This will definately help you....
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 28 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100