in Education by
I want to make a button Go To Cart visible after adding a product into cart. But when page gets reload it shows Add to cart button only /This is my presentation layer code/ protected void ddlimginfo_ItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandName=="addtocart") { Label price = e.Item.FindControl("lblprice") as Label; string prc = price.Text; DateTime pdate = Convert.ToDateTime(System.DateTime.Now); string postdate = (pdate.ToString("yyyy-mm-dd", CultureInfo.InvariantCulture)); Button btnaddcart = e.Item.FindControl("btnaddcart") as Button; Button btngocart = e.Item.FindControl("btngocart") as Button; //balobj.dalCart((Session["uip"]).ToString(), Convert.ToInt32(Sessio n["id"]), qty, prc,pdate); //DateTime existingDate =Convert.ToDateTime(balobj.getdate((Session["uip"]).ToString())); //string exdate = (existingDate.ToString("yyyy-mm-dd", CultureInfo.InvariantCulture)); balobj.dalCart(Convert.ToString(Session["uip"]), Convert.ToInt32(Session["id"]), 1, prc, pdate); if ((Session["uip"]) != null) { Session["count"] = balobj.cartcount((Session["uip"]).ToString()); DataTable dt = new DataTable(); dt = balobj.balgocart(Convert.ToString(Session["uip"]), Convert.ToInt32(Session["id"])); if (dt.Rows.Count > 0) { //Session["count"] = balobj.cartcount((Session["uip"]).ToString()); btnaddcart.Visible = false; btngocart.Visible = true; Response.Redirect("infoproduct.aspx"); } else { //Session["count"] = balobj.cartcount((Session["uip"]).ToString()); btnaddcart.Visible = true; btngocart.Visible = false; Response.Redirect("infoproduct.aspx"); } //Response.Write(Session["count"]); //Response.End(); //Response.Redirect("infoproduct.aspx"); } /This is my BAL code/ //Go to cart button visible public DataTable balgocart(string uip, int proid) { try { return dalobj.dalgocart(uip, proid); } catch { throw; } finally { dalobj = null; } } /This is my DAL code/ //Code to visible button go to cart public DataTable dalgocart(string uip, int proid) { MySqlConnection con = new MySqlConnection(str); try { con.Open(); MySqlCommand cmd = new MySqlCommand("spbtngocart", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("spuip", uip); cmd.Parameters.AddWithValue("spproid", proid); MySqlDataAdapter da = new MySqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); return dt; } catch (Exception ex) { throw ex; } finally { con.Close(); } } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You just need to rebind the control after making changes as DataList1.DataBind();

Related questions

0 votes
    I have two submit buttons and a few textboxes on my page. When I enter details in the textbox and hit ... model.FirsttName) @Html.TextBoxFor(model => model.LastName) Get History...
asked May 22, 2022 in Education by JackTerrance
0 votes
    I have two submit buttons and a few textboxes on my page. When I enter details in the textbox and hit ... model.FirsttName) @Html.TextBoxFor(model => model.LastName) Get History...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I have two submit buttons and a few textboxes on my page. When I enter details in the textbox and hit ... model.FirsttName) @Html.TextBoxFor(model => model.LastName) Get History...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have a master page with a form element and the defaultbutton attribute set to a server-side ImageButton. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 16, 2022 in Education by JackTerrance
0 votes
    I have a fileupload option in my project. It inclueds a query which returns a dataset. It works fine ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    I have tried many solution online but I am unable to fix. First off all i check in bin and it ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I am using MQTT client library from this link https://www.hivemq.com/blog/mqtt-client-library-encyclopedia- ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    So the problem is i don't get get a value from textbox field on GridView RowUpdating event. Here ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    I have been developing a webpage which uses n number of dropdownlists which are binding dynamically inside a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    Greetings! I have a DropDownList within a FormView which are bound to XmlDataSources: In the page's ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Greetings! I have a DropDownList within a FormView which are bound to XmlDataSources: In the page's ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I have created an empty web application project in visual studio 2010 and have addd the following model ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I have created an empty web application project in visual studio 2010 and have addd the following model ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    The Function Key F5 is used in a webpage to___________the page (a) Exit (b) Create another window (c) Reload (d) Add a new tab Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    I have a Login control placed inside LoginView control contained within a PANEL. I want to set login button ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
...