Click here to Skip to main content
Rate this: bad
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
if i want to print the name into label
i write
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 19:04pm
Edited 6-Nov-12 19:15pm
Neelam Chandra (8015059) at 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 at 7-Nov-12 0:17am
store this way value in session
I thing you are storing the "DataRowView" object in session.
Milind Thakkar at 7-Nov-12 0:23am
Why you reposting questions with same subject
If the question is different, atleast change subject appropriately. This confuses members.

1 solution

Rate this: bad
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.
Dee_Bee at 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
0 Dnyaneshwar@Pune 719
1 CPallini 245
2 TheRealSteveJudge 240
3 CHill60 235
4 Umer Akram 190
0 Sergey Alexandrovich Kryukov 9,078
1 OriginalGriff 6,771
2 Peter Leow 4,282
3 Zoltán Zörgő 3,809
4 Richard MacCutchan 2,661

Advertise | Privacy | Mobile
Web02 | 2.8.150128.1 | Last Updated 7 Nov 2012
Copyright © CodeProject, 1999-2015
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