You are on page 1of 2

AddtoCart.

aspx Webform Coding


-----------------------------

Response.Redirect("EditOrder.aspx?sno=" + GridView1.SelectedRow.Cells[0].Text);

----------------------------

EditOrder.aspx

Important Namespaces Used


---------------------------

using System.Data;
using System.Data.SqlClient;

---------------------------

Pageload Coding
---------------------------

if (IsPostBack)
{
}
else
{
if (Request.QueryString["sno"] != null)
{
dt = (DataTable)Session["buyitems"];

for (int i = 0; i <= dt.Rows.Count - 1; i++)


{
int sr;
int sr1;
sr = Convert.ToInt32(dt.Rows[i]["sno"].ToString());
Label3.Text = Request.QueryString["sno"];
Label4.Text = sr.ToString();
sr1 = Convert.ToInt32(Label3.Text);
//sr1 = sr1 + 1;

if (sr == sr1)
{
Label3.Text = dt.Rows[i]["sno"].ToString();
Label4.Text = dt.Rows[i]["productid"].ToString();
Label5.Text = dt.Rows[i]["productname"].ToString();
DropDownList1.Text = dt.Rows[i]["quantity"].ToString();
Label6.Text = dt.Rows[i]["price"].ToString();
Label7.Text = dt.Rows[i]["totalprice"].ToString();

break;

}
}
}
else
{
}
}

----------------------

DropDownList SelectedIndexChanged
----------------------------------

int q;
q = Convert.ToInt32(DropDownList1.Text);
int cost;
cost = Convert.ToInt32(Label6.Text);
int totalcost;
totalcost = cost * q;
Label7.Text = totalcost.ToString();

----------------------------------

Save Button Coding


----------------------------------

dt = (DataTable)Session["buyitems"];

for (int i = 0; i <= dt.Rows.Count - 1; i++)


{
int sr;
int sr1;
sr = Convert.ToInt32(dt.Rows[i]["sno"].ToString());

sr1 = Convert.ToInt32(Label3.Text);

if (sr == sr1)
{
dt.Rows[i]["sno"] = Label3.Text;
dt.Rows[i]["productid"] = Label4.Text;
dt.Rows[i]["productname"] = Label5.Text;
dt.Rows[i]["quantity"] = DropDownList1.Text;
dt.Rows[i]["price"] = Label6.Text;
dt.Rows[i]["totalprice"] = Label7.Text;
dt.AcceptChanges();

break;

}
}
Response.Redirect("AddToCart.aspx");
}

----------------------------------

You might also like