Click here to Skip to main content
12,957,007 members (62,143 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi Can Some one tell me how to populate the value from a session to the controls in a page.I have the values stored in a database..I created a connection to db and the filled the values in the session..Now I wanna populate the value to the control..I have done this peice of code..but this doesnt seems to be working
//connect to database for UserSetting stable
    SqlConncetion conn = new SqlConncetion(@"Server=localhost;      Database=LCLDatabase_DEV; Integrated Security=True);
//Create DataAdapter Object
SqlDataAdapter  adapter = new SqlDataAdapter  ("Select id,valueFrom user where UserName="Samantha",conn);
//Create a Dataset 
DataSet ds=new DataSet();
//Fill dataset using the query defined for DataAdapter
adapter.Fill(this.ds,"user );
foreach(DataRow row in ds.Tables["user "].Rows)

Above I have stored the value in a session from db now I wanna populate it back to control when the user samantha logsin
   foreach(controls ctrl in page. controls)
    ctrl.value= Session[ctrl.ID].value

can someone tell me how to proceed further??
Posted 21-Feb-13 18:19pm
Updated 22-Feb-13 10:08am
richcb 22-Feb-13 16:09pm
You are not calling the correct session variable when you are tring to take it back out. You set Session["id"] and that is what you have to use when taking your value back out of session.

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

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,924
CHill60 3,550
Maciej Los 3,312
ppolymorphe 2,120
Jochen Arndt 1,973

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2017
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