Silver Archer Silver Archer - 26 days ago 18
ASP.NET (C#) Question

How to Pass Values Between Pages?

I am doing Airline Reservation System using GUI with ASP.NET in C#.
What I want is assign seats for user, after a user assign that seats, that seat cannot be assigned by others again. I try to use increment do this but instead of 1+1 = 2(that means seat number 2 is the next to be assigned), the system gives me 1+1=11. How can I do what I want?

I have 5 interfaces for this, and I need this assigned value stored in whole running process.
This is my code for the reservation button, I have 2 for it, First Class and Economy Class. Only 5 seats for First Class and 15 seats for Economy Class.
How can I do ?

protected void Button1_Click(object sender, EventArgs e)
{
Session["seats"] = "First Class";
if (firstseatnum > 5)
{
MessageBox.Show("Sorry, the first class seats was fully booked. Can you change to economy class?");
Response.Redirect("reservation.aspx");
}
else
{
++firstseatnum;
totalseatnum1 = Convert.ToInt32(firstseatnum+seatnum);
Response.Redirect("~/information.aspx?firstseatnum="+firstseatnum+"&seatnum="+totalseatnum1);
}
}

protected void Button2_Click(object sender, EventArgs e)
{
Session["seats"] = "Economy Class";
if (economyseatnum > 20)
{
MessageBox.Show("Sorry, the economy class seats was fully booked. Can you change to first class?");
Response.Redirect("reservation.aspx");
}
else
{
++economyseatnum;
totalseatnum2 = Convert.ToInt32(economyseatnum + seatnum);
Response.Redirect("information.aspx?economyseatnum=" + economyseatnum + "&seatnum="+totalseatnum2);
}
}


Please help me, thank you.

Answer

Presumably seatnum is a string.

If so, try

totalseatnum1 = firstseatnum + Convert.ToInt32(seatnum);

and

totalseatnum2 = economyseatnum + Convert.ToInt32(seatnum);
Comments