My Gridview has following Fields
ID Product Price ($)
1 Pencil 1
2 Pen 1
3 Rubber 2
我想计算Grudview 标语......的总价格。
总价格=4
如何使用VB。 NET?
My Gridview has following Fields
ID Product Price ($)
1 Pencil 1
2 Pen 1
3 Rubber 2
我想计算Grudview 标语......的总价格。
总价格=4
如何使用VB。 NET?
http://msdn.microsoft.com/en-us/library/ms972833.aspx”rel=“nofollow” GridView ASP.NET 2.0: 显示脚注数据
采用可计算数据的方法,以获得所有价格的总和,并处理罗达塔·博恩通,以制定脚注案文:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
BindData()
End If
End Sub
Private Sub BindData()
Dim tbl As New DataTable
Dim col As New DataColumn("ID", GetType(Int32))
tbl.Columns.Add(col)
col = New DataColumn("Product", GetType(String))
tbl.Columns.Add(col)
col = New DataColumn("Price", GetType(Double))
tbl.Columns.Add(col)
Dim row As DataRow = tbl.NewRow
row("ID") = 1
row("Product") = "Pencil"
row("Price") = 1
tbl.Rows.Add(row)
row = tbl.NewRow
row("ID") = 1
row("Product") = "Pen"
row("Price") = 1
tbl.Rows.Add(row)
row = tbl.NewRow
row("ID") = 1
row("Product") = "Rubber"
row("Price") = 2
tbl.Rows.Add(row)
Me.GridView1.ShowFooter = True
Me.GridView1.DataSource = tbl
Me.GridView1.DataBind()
End Sub
Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.Footer Then
Dim tbl As DataTable = DirectCast(GridView1.DataSource, DataTable)
Dim total As Double = DirectCast(tbl.Compute("SUM(Price)", Nothing), Double)
e.Row.Cells(2).Text = total.ToString
End If
End Sub
Sub BindAmount()
Dim r As DataGridViewRow
If DataGridView1.RowCount > 0 Then
Dim TAmt As Decimal = 0.0
For Each r In DataGridView1.Rows
If r.Visible = True Then
TAmt = TAmt + r.Cells("PRICE").Value
TXT_PRICE.Text = TAmt
End If
Next
Else
TXT_PRICE.Text = 0
End If
End Sub
**LOAD ON KEYDOWN
In my webpages I have references to js and images as such: "../../Content/Images/"Filename" In my code if I reference a file as above, it doesnt work so i have to write: "c:/miscfiles/"filename" 1-...
I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...
Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
I m looking for best practices here. Sorry. I know it s subjective, but there are a lot of smart people here, so there ought to be some "very good" ways of doing this. I have a custom object called ...
I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...
i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...
For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?
I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!