locked
show pervious page data in a next page using session variable.(in table format) RRS feed

  • Question

  • User-2131228925 posted

    Hello,

    I want to show my data in next page with well formated in table.I all ready write code for session which show data in next page.but i want to show it in table format and i also want to comapre in database for a price and show too.

    this is my code for next page :

    protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["CheckedItems"] != null)
            {
                ArrayList a = (ArrayList)Session["CheckedItems"];
                if (a.Count > 0)
                {
                    foreach (string chkBoxListItemValue in a)
                        if (chkBoxListItemValue == "None")
                        {
                            Response.Write("");
                        }
                        else
                        {
                            Response.Write("<br/>");
                        Response.Write(Environment.NewLine+"<br>" + chkBoxListItemValue);
                    }
                }
               
            }   
        }

    this code show me data but as i say iwant it in table format and want to comapare session varibles in database i want to show price accoding that particular product.

    The Pervious page code:

    protected void btnsubmit_Click(object sender, EventArgs e)    { ArrayList a = new ArrayList();
           foreach (Control c in Panel1.Controls)
            {
                if (c is RadioButtonList)
                {
                    RadioButtonList rbl = (RadioButtonList)c;
                    foreach (ListItem rblist in rbl.Items)
                    {
                        if (rblist.Selected)
                        {
                            a.Add(rblist.Text);
                            Response.Write(a);
                        }
                        else
                        {
    
                        }
                    }
                }
                else if (c is CheckBoxList)
                {
                    CheckBoxList c1 = (CheckBoxList)c;
                    foreach(ListItem  cblist in c1.Items)
                    { if(cblist.Selected)
                        {
                            a.Add(cblist.Text);
                            Response.Write(a);
                        }
                        else 
                        {
                            
                        }
                    }
                }
            }
    
            Session["CheckedItems"] = a;
            Response.Redirect("poleconfigdetail.aspx");
     }



     Its urgent plz reply as soon as possible.

     
     
     
    Wednesday, January 19, 2011 2:36 PM

Answers

  • User1006193418 posted

    Hi,

    Please have a try on this code. It draws a table for all the values in the ArrayList Session["CheckedItems"] on the page.

        protected void Page_Load(object sender, EventArgs e)
        {
            Table tb = new Table();
            tb.BorderWidth = 1;
            tb.BorderColor = System.Drawing.Color.Black;
    
            if (Session["CheckedItems"] != null)
            {
                ArrayList a = (ArrayList)Session["CheckedItems"];
    
                foreach (string chkBoxListItemValue in a)
                {
                    if (chkBoxListItemValue != "None")
                    {
                        TableRow tr = new TableRow();
                        
                        TableCell tc = new TableCell();
                        tc.BorderWidth = 1;
                        tc.Text = chkBoxListItemValue;
    
                        tr.Cells.Add(tc);
                        tb.Rows.Add(tr);
                    }
                }
                form1.Controls.Add(tb);
            }
        }

    Best Regards,
    Shengqing Yang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 26, 2011 1:28 AM

All replies

  • User712082397 posted

    1. protected void Page_Load(object sender, EventArgs e)   
    2.     {   
    3.         if (Session["CheckedItems"] != null)   
    4.         {   
    5.             ArrayList a = (ArrayList)Session["CheckedItems"];   
    6.             if (a.Count > 0)   
    7.             {   
    8.                 foreach (string chkBoxListItemValue in a)   
    9.                     if (chkBoxListItemValue == "None")   
    10.                     {   
    11.                         Response.Write("");   
    12.                     }   
    13.                     else  
    14.                     {   
    15.                         Response.Write("<br/>");   
    16.                     Response.Write(Environment.NewLine+"<br>" + chkBoxListItemValue);   
    17.                 }   
    18.             }   
    19.               
    20.         }      
    21.     }  

     

    Within the page load event of next page, use HTML table tag to construct your HTML table. Within that table, you can then define your rows and columns too. For price comparision, do a database query and then fetch and display results whereever you want them to be.

    Wednesday, January 19, 2011 3:07 PM
  • User-2131228925 posted

     if possible for you then plz write down code for me.

    Wednesday, January 19, 2011 3:20 PM
  • User712082397 posted

    Here is a good article that shows how to do that. 

    http://www.dotnetcurry.com/ShowArticle.aspx?ID=135

    Hope it helps. 

    Wednesday, January 19, 2011 3:32 PM
  • User1006193418 posted

    Hi,

    Please have a try on this code. It draws a table for all the values in the ArrayList Session["CheckedItems"] on the page.

        protected void Page_Load(object sender, EventArgs e)
        {
            Table tb = new Table();
            tb.BorderWidth = 1;
            tb.BorderColor = System.Drawing.Color.Black;
    
            if (Session["CheckedItems"] != null)
            {
                ArrayList a = (ArrayList)Session["CheckedItems"];
    
                foreach (string chkBoxListItemValue in a)
                {
                    if (chkBoxListItemValue != "None")
                    {
                        TableRow tr = new TableRow();
                        
                        TableCell tc = new TableCell();
                        tc.BorderWidth = 1;
                        tc.Text = chkBoxListItemValue;
    
                        tr.Cells.Add(tc);
                        tb.Rows.Add(tr);
                    }
                }
                form1.Controls.Add(tb);
            }
        }

    Best Regards,
    Shengqing Yang

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 26, 2011 1:28 AM