Click here to Skip to main content
15,896,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to pass a DropDownList from one page to the other.
The code from the first ASPX page is:
C#
if (validLogon)

       {
           Session["FacilityNames"] = FacilityNames;
           Session["User"] = txtUser;
           Response.Redirect("Default2.aspx");
       }

Where FacilityName is a string array
The code from the Second ASPX page is:
C#
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string fac = (string)Session["FacilityNames"].ToString();

           foreach (var sss in fac)
        {
            ddlFacilities.Items.Add(sss.ToString());
        }

The fac string variable is populated with "System String[] instead of the string array specified from the first page.
Posted

ToString() is overload of ToString for session. so write like below.


C#
protected void Page_Load(object sender, EventArgs e)
    {
        string fac = (string)Session["FacilityNames"];

           foreach (var sss in fac)
        {
            ddlFacilities.Items.Add(sss.ToString());
        }
 
Share this answer
 
v2
 
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