如何在gridview中计算税,数量,单价以找出购物车中的总计 [英] how to calculate tax, quantity,unitprice in gridview to find out the grand total in shopping cart

查看:166
本文介绍了如何在gridview中计算税,数量,单价以找出购物车中的总计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,先生,


项目:在线购物

任务:购物车

我想在gridview中显示购物车详细信息,但是我想在gridview中编辑,更新和删除商品,请在asp.net中发送编码路径

我也搜索该网站,但仍在执行相同的过程.请帮帮我.



通过

Bala

Hi sir,


Project: Online shopping

Task: shopping cart

I want show the shopping cart details in gridview but I want edit, update and remove items in grid view please send the coding path in asp.net

I search the website also, but still am doing same process. please help me.



By

Bala

推荐答案

在网格视图中,

In a grid view,

<asp:gridview id="GridView1" runat="server" xmlns:asp="#unknown">
AutoGenerateColumns="False"
DataKeyNames="ID" DataSourceID="SqlDataSource1"
OnRowDataBound="GridView1_RowDataBound"
ShowFooter="True" AllowPaging="True" PageSize="5"
BackColor="#ffffff" BorderColor="AliceBlue"
BorderStyle="None" BorderWidth="1px"
CellPadding="3"
CellSpacing="2" FooterStyle-BackColor="#da821e"
FooterStyle-ForeColor="#ffffff"
RowStyle-BackColor="#003366"
RowStyle-ForeColor="#ffffff"
AlternatingRowStyle-BackColor="#da821e">
<columns>
<asp:boundfield datafield="ID" headertext="ID">
InsertVisible="False" ReadOnly="True"
SortExpression="ID" />
<asp:boundfield datafield="Name" headertext="Name">
InsertVisible="False" ReadOnly="True"
SortExpression="Name" FooterText="Total"/>
<asp:templatefield headertext="Amount">
<itemtemplate>
<asp:label id="lblAmount" runat="server">
Text='<%# "


" + Eval("Amount" ).ToString()%>' > </ asp:label > </ itemtemplate > < footertemplate> < asp:label id = " runat = " > </ asp:label > </ 页脚模板 > </ asp:templatefield > </ asp:boundfield > </ asp:boundfield > </ > < pagerstyle forecolor = " horizo​​ntalalign = " 居中"/> < headerstyle backcolor = " font-bold = " > ForeColor = " /> </ 标题样式 > </ asp:gridview > < asp:sqldatasource id = " runat = " xmlns:asp = " > ConnectionString = "
"+Eval("Amount").ToString()%>'> </asp:label> </itemtemplate> <footertemplate> <asp:label id="lblTotal" runat="server"></asp:label> </footertemplate> </asp:templatefield> </asp:boundfield></asp:boundfield></columns> <pagerstyle forecolor="#8C4510" horizontalalign="Center" /> <headerstyle backcolor="#da821e" font-bold="True"> ForeColor="White" /> </headerstyle></asp:gridview> <asp:sqldatasource id="SqlDataSource1" runat="server" xmlns:asp="#unknown"> ConnectionString="<%


ConnectionStrings:ConnectionString%>" SelectCommand = " > </ asp:sqldatasource > < pre lang = " >>
ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [ID], [Name], [Amount] FROM [Expenses]"> </asp:sqldatasource> <pre lang="text">


在aspx页面中


in aspx page

public partial class _Default : System.Web.UI.Page
{
decimal grdTotal = 0;
protected void Page_Load(object sender, EventArgs e)
{

}
.protected void GridView1_RowDataBound
(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
decimal rowTotal = Convert.ToDecimal
(DataBinder.Eval(e.Row.DataItem, "Amount"));
grdTotal = grdTotal + rowTotal;
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lbl = (Label)e.Row.FindControl("lblTotal");
lbl.Text = grdTotal.ToString("c");
}
}
}


这篇关于如何在gridview中计算税,数量,单价以找出购物车中的总计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆