.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

problm with session values.

Posted By: shabazsh     Posted Date: October 16, 2008    Points:2   Category :C#
ITEMS.ASPX.............
ArrayList item_name = new ArrayList();
ArrayList item_desc = new ArrayList();

void AddItems()
{
if (Session.Count > 1)
{
item_name = (ArrayList)Session["item_name"];
item_desc = (ArrayList)Session["item_desc"];
}
}

protected void gv_items_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
AddItems();
GridViewRow row = gv_items.Rows[e.NewSelectedIndex];
try
{
item_name.Add(row.Cells[2].Text);
item_desc.Add(row.Cells[3].Text);
}
catch
{
item_name = (ArrayList)Session["item_name"];
item_desc = (ArrayList)Session["item_desc"];
}
Session["item_name"] = item_name;
Session["item_desc"] = item_desc;

Session["continue"] = @"Items.aspx";
Response.Redirect("~/Cart.aspx");
}


CART.ASPX.......................

ArrayList al_name;
ArrayList al_price;

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
al_name = (ArrayList)Session["item_name"];
al_price = (ArrayList)Session["item_desc"];
for (int i = 0; i < al_name.Count; i++)
{
lb_cart.Items.Add(al_name[i].ToString() + " - " + al_price[i].ToString());
}
}
}




Above is the code for both the pages that i m using but the thing is if i add an item into the cart then continue the shopping when i add another item, this new item is overwriting on the first item. so plz hel me where the roblm is as i m unable to find it out. plz

Responses
Author: Vivek             
Posted Date: October 18, 2008     Points: 5   

Test Post



.NavLinkDeSelected
{
height:25px;
color:Maroon;
font-family:Arial;
font-size:large;
font-weight:bold;
text-decoration:none;
}

protected void btnDisplayAll_Click(object sender, EventArgs e)
{
//BIND Grid
clsForum objForum = new clsForum();
DataTable dtForum = objForum.SelectAll();

//Display No Record Message if no data found in gridview
if (dtForum.Rows.Count > 0)
{
lblNoRecordsFound.Visible = false;
GridView1.DataSource = dtForum;
GridView1.DataBind();
}
else
{
lblNoRecordsFound.Visible = true;
}
}





Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend