<asp:GridView ID="gv_CartProduct" runat="server" AutoGenerateColumns="False" onRowCommand="gv_CartProduct_OnRowCommand"> <Columns> <asp:TemplateField HeaderText="Title"> <ItemTemplate> <asp:Label ID="lbl_title" Text='<%# Eval("title") %>' runat="server"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Image"> <ItemTemplate> <asp:Image ID="imgPreview" ImageUrl='<%# Eval("image") %>' runat="server" Height="80px" Width="80px" /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="price" HeaderText="Price" DataFormatString="{0:0.00}" /> <asp:TemplateField HeaderText="Quantity"> <ItemTemplate> <asp:TextBox ID="tb_quantity" runat="server" CommandArgument='<%# Eval("title")%>' Text='<%# Eval("qty") %>' ></asp:TextBox> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <asp:LinkButton ID="btn_delete" runat="server" Text="Delete" CommandName="deleterow" CommandArgument='<%# Eval("title") %>' OnClientClick="return confirm('Do you want to delete product?');" ></asp:LinkButton> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
<asp:Button ID="btn_Checkout" runat="server" OnClick="btn_Checkout_Click" Text="Checkout" />
protected void btn_Checkout_Click(object sender, EventArgs e) { CartBLL cbll = new CartBLL(); Cart c1 = new Cart(); username = (string)(Session["username"]); foreach (GridViewRow row in gv_CartProduct.Rows) { if (row.RowType == DataControlRowType.DataRow) { string qtystring = ((TextBox)(row.FindControl("tb_quantity"))).Text; string title = ((Label)row.FindControl("lbl_title")).Text; int amount = Convert.ToInt32(row.Cells[2].Text); string amountInString = amount.ToString(); string redirectUrl = ""; //Mention URL to redirect content to paypal site redirectUrl += "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=" + ConfigurationManager.AppSettings["paypalemail"].ToString(); //First name I assign static based on login details assign this value redirectUrl += "&first_name=" + username; //Product Name redirectUrl += "&item_name=" + title; //quantity redirectUrl += "&quantity=" + qtystring; //Business contact paypal EmailID redirectUrl += "&business=121366S-facilitator@mymail.nyp.edu.sg"; //price if any, or available or using shopping cart system redirectUrl += "&amount=" + amount; //If transactioin has been successfully performed, redirect SuccessURL page- this page will be designed by developer redirectUrl += "&return=" + ConfigurationManager.AppSettings["SuccessURL"].ToString(); //If transactioin has been failed, redirect FailedURL page- this page will be designed by developer redirectUrl += "&cancel_return=" + ConfigurationManager.AppSettings["FailedURL"].ToString(); Response.Redirect(redirectUrl); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)