Click here to Skip to main content
15,893,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have DropDownList on Login Page. Now i want to show dropdown selected text on all pages in lable like we show Login Username on all pages . How can i do this

please Help...........
Posted
Comments
Sanket Saxena 12-Sep-14 9:06am    
The solution is in your question itself only if you know how to display the Username on all pages.

Use Session variable.

:)

on click store your dropdownlist selected text in session

C#
protected void btn_Click(object sender, EventArgs e)
{
// code
  Session["abc"] = dropdownName.Selected.Text;
}


check session variable and assign session stored value in label

C#
protected void Page_Load(object sender, EventArgs e)
{
    // code
   if (Session["abc"] != null)
   {
     // code
     lblShow.Text = Session["abc"].ToString();
   }
}

Use Master Page that best suitable for this kind of situation
 
Share this answer
 
Comments
Member 11014751 12-Sep-14 9:28am    
Thank You :)
Protected void btn_click(object sender, EventArgs e)
{

Session["UserID"] = dropdownlistname.SelectedItem.Text;

}
 
Share this answer
 
Comments
Member 11014751 12-Sep-14 9:28am    
Thank You :)
You can use this code in your login page.
C#
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
       Session["MyLabel"] = DropDownList1.SelectedItem.Text;
}


and you can use this value in your any page, like this.

C#
Label1.Text = Session["MyLabel"].ToString();
 
Share this answer
 
v2
Comments
Member 11014751 12-Sep-14 9:28am    
Thank You :)
BharatPrajapati212 12-Sep-14 10:04am    
You are welcome. Will you formally accept the answer (green "Accept" button)?
Store it in a Session variable..like this..
C#
 Session["UserRole"]=convert.tostring(DropDownList1.SelectedItem.Text)

and Show it where you want to show.. 
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900