TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jitendra Kumar
NA
189
23.2k
Can you explain this code? I am not able to get this?
Aug 5 2018 11:55 PM
protected void btnaddtocart_Click(object sender, EventArgs e)
{
if (Session["cart"] == null)
{
SqlParameter[] prm = new SqlParameter[1];
ds = new DataSet();
prm[0] = new SqlParameter("@id", pid);
ds = an.ReturnSpParamDataSet("tbl_products_info12", prm);
if (ds.Tables[0].Rows.Count > 0)
{
DataSet pds;
pds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("pid"));
dt.Columns.Add(new DataColumn("productname"));
dt.Columns.Add(new DataColumn("quantity"));
dt.Columns.Add(new DataColumn("price"));
dt.Columns.Add(new DataColumn("discount"));
dt.Columns.Add(new DataColumn("discountprice"));
dt.Columns.Add(new DataColumn("shippingcharge"));
pds.Tables.Add(dt);
DataRow dr = pds.Tables[0].NewRow();
dr["pid"] = pid;
dr["productname"] = ds.Tables[0].Rows[0]["product_name"].ToString();
dr["quantity"] = txtquantity.Text;
dr["price"] = ds.Tables[0].Rows[0]["price"].ToString();
dr["discount"] = ds.Tables[0].Rows[0]["discount"].ToString();
dr["discountprice"] = ds.Tables[0].Rows[0]["discountprice"].ToString();
dr["shippingcharge"] = ds.Tables[0].Rows[0]["shipingcharge"].ToString();
pds.Tables[0].Rows.Add(dr);
Session.Add("cart", pds);
}
Response.Redirect("~/cart.aspx");
}
else
{
DataSet pds = (DataSet)Session["cart"];
SqlParameter[] prm = new SqlParameter[1];
ds = new DataSet();
prm[0] = new SqlParameter("@id", pid);
ds = an.ReturnSpParamDataSet("tbl_products_info12", prm);
if (ds.Tables[0].Rows.Count > 0)
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("pid"));
dt.Columns.Add(new DataColumn("productname"));
dt.Columns.Add(new DataColumn("quantity"));
dt.Columns.Add(new DataColumn("price"));
dt.Columns.Add(new DataColumn("discount"));
dt.Columns.Add(new DataColumn("discountprice"));
dt.Columns.Add(new DataColumn("shippingcharge"));
pds.Tables.Add(dt);
DataRow dr = pds.Tables[0].NewRow();
dr["pid"] = pid;
dr["productname"] = ds.Tables[0].Rows[0]["product_name"].ToString();
dr["quantity"] = txtquantity.Text;
dr["price"] = ds.Tables[0].Rows[0]["price"].ToString();
dr["discount"] = ds.Tables[0].Rows[0]["discount"].ToString();
dr["discountprice"] = ds.Tables[0].Rows[0]["discountprice"].ToString();
dr["shippingcharge"] = ds.Tables[0].Rows[0]["shipingcharge"].ToString();
pds.Tables[0].Rows.Add(dr);
Session.Add("cart", pds);
}
Response.Redirect("~/cart.aspx");
}
}
Reply
Answers (
2
)
How do you color cell of the listview ?
Insert PDF in database c#