我有一个按钮,用于将已添加到网格视图中的所有项目发送到付费网站。目前,它只将第一列项目发送到paypal网站。例如,我在购物车中有项目A和项目B.只有项目A信息将进入paypal网站,而不是项目B.请帮助我。谢谢,最诚挚的问候!:D
网格视图代码:
<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>
btn_checkout_Click代码:
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); } } }