Click here to Skip to main content
12,450,981 members (58,436 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
I have retrieved a value from database into session as
with query i got username from database into var p
then
session["username"]=p.ToString();

if i want to print the name into label
i write
label.Text=session["username"].ToString();
it should print only username but it is printing column name too(like {username=aman})
what should i do?
remember i'm getting value from database
Posted 6-Nov-12 18:04pm
Updated 6-Nov-12 18:15pm
v2
Comments
Neelam Chandra (8015059) 7-Nov-12 0:08am
   
Which type of variable 'p' is? can u show the code u storing data in variable p?
Sanjay K. Gupta 7-Nov-12 0:17am
   
store this way value in session
session["username"]=p["UserName"].ToString();
I thing you are storing the "DataRowView" object in session.
Milind Thakkar 7-Nov-12 0:23am
   
Why you reposting questions with same subject http://www.codeproject.com/Questions/489669/sessionplusvalueplusretrievel

If the question is different, atleast change subject appropriately. This confuses members.

1 solution

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

Solution 1

string str = session["username"].ToString();
str = str.Remove(0,9);
label.Text= str;


It removes 'username=' and displays only the text 'aman'.
Hope you can use remove function and (0,9) as 'username=' is same for every data base call here in your program.
  Permalink  
Comments
Dee_Bee 7-Nov-12 23:23pm
   
did you try this ?

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


Advertise | Privacy | Mobile
Web01 | 2.8.160826.1 | Last Updated 7 Nov 2012
Copyright © CodeProject, 1999-2016
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