ผมจะคำนวณผลรวมเงินใน gridview ยังไงครับ แนะนำด้วยครับ
ผมต้องการที่จะ sum เงินรวมครับจะทำอย่างไร ผมได้รวมเงินของ จำนวน*ราคา ไว้แล้ว และต้องการ ผลรวมทั้งหมดครับ โดยไว้ที่ ด้านล่างสุดของแถว amount ครับ
Code (VB.NET)
Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim sumQty As Double
Dim sumTotal As Double
For i As Integer = 0 To GridView1.Rows.Count - 1
Dim Qty1 As Double = DirectCast(GridView1.Rows(i).FindControl("Quantity"), Label).Text()
Dim Qty2 As Double = DirectCast(GridView1.Rows(i).FindControl("ListPrice"), Label).Text()
Dim Qty3 As Label = DirectCast(GridView1.Rows(i).FindControl("Amount"), Label)
Dim Qty4 As Label = DirectCast(GridView1.Rows(i).FindControl("Total"), Label)
sumQty = Qty1 * Qty2
Qty3.Text = FormatNumber(sumQty, 2)
sumTotal = ????
Qty4.Text = FormatNumber(sumTotal, 2)
Next
End Sub
Tag : .NET, Ms SQL Server 2012, VS 2008 (.NET 3.x), VS 2010 (.NET 4.x)
Date :
2017-08-30 11:23:51
By :
Mixs
View :
2207
Reply :
10
ช่วยทีครับ ผมหาวิธีทำมาครึ่งวันแล้วครับ ผมแค่ต้องการให้ column ใน gridview มัน + กันครับ จะใช้คำสั่งแบบไหนครับ
ประวัติการแก้ไข 2017-08-30 15:18:36
Date :
2017-08-30 15:07:19
By :
Mixs
Date :
2017-08-31 07:51:47
By :
Mixs
ลองดูครับ
ไม่มั่นใจเหมือนกัน
Code (VB.NET)
Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim sumQty As Double
Dim sumTotal As Double
'เพิ่ม
sumtotal=0
For i As Integer = 0 To GridView1.Rows.Count - 1
Dim Qty1 As Double = DirectCast(GridView1.Rows(i).FindControl("Quantity"), Label).Text()
Dim Qty2 As Double = DirectCast(GridView1.Rows(i).FindControl("ListPrice"), Label).Text()
Dim Qty3 As Label = DirectCast(GridView1.Rows(i).FindControl("Amount"), Label)
Dim Qty4 As Label = DirectCast(GridView1.Rows(i).FindControl("Total"), Label)
sumQty = Qty1 * Qty2
Qty3.Text = FormatNumber(sumQty, 2)
'เพิ่ม
sumTotal += sumQty
Qty4.Text = FormatNumber(sumTotal, 2)
Next
End Sub
Date :
2017-08-31 08:10:22
By :
fonfire
มัน error อะครับ The object invoked has disconnected from its clients อันนี้ผมคิดเลขจากใน column gridview เลยครับ จะแสดง total ใน footer ของ amount ครับ
Date :
2017-08-31 08:27:51
By :
Mixs
Code (VB.NET)
ใน Gridview
ปรกกาศตัวแปร public ไว้บนสุดใต้ Class
Dim sumTotal As Decimal = 0
<asp:TemplateField HeaderText="Amount">
<FooterTemplate>
<asp:Label ID="LblTotalAmount" runat="server" Width="100%" CssClass="text-right"></asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="LblAmount" runat="server" Width="100%" CssClass="text-right"
Text='<%# DataBinder.Eval(Container, "DataItem.Amount") %>'></asp:Label>
</ItemTemplate>
<HeaderStyle Width="10%" />
</asp:TemplateField>
Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim LblAmount As Label = CType(e.Row.FindControl("LblAmount "), Label)
sumTotal+= CDec(LblAmount .Text)
End Sub
If e.Row.RowType = DataControlRowType.Footer Then
Dim LblTotalAmount As Label = CType(e.Row.FindControl("LblTotalAmount "), Label)
LblTotalAmount .Text = sumTotal.ToString("N2")
End If
End Sub
Date :
2017-08-31 09:43:48
By :
guest
มันขึ้น error เหมือนเดิมครับ แล้วข้อมูลก็แสดงไม่ครบครับ ผมทำตรงไหนผิดหรือเปล่าครับ
Code (VB.NET)
Dim sumTotal As Decimal = 0
Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim sumQty As Double
For i As Integer = 0 To GridView1.Rows.Count - 1
Dim Qty1 As Double = DirectCast(GridView1.Rows(i).FindControl("lblQuantity"), Label).Text()
Dim Qty2 As Double = DirectCast(GridView1.Rows(i).FindControl("lblListPrice"), Label).Text()
Dim Qty3 As Label = DirectCast(GridView1.Rows(i).FindControl("lblAmount"), Label)
Dim Qty4 As Label = DirectCast(GridView1.Rows(i).FindControl("lblTotal"), Label)
sumQty = Qty1 * Qty2
Qty3.Text = FormatNumber(sumQty, 2)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim LblAmount As Label = CType(e.Row.FindControl("LblAmount "), Label)
sumTotal += CDec(lblAmount.Text)
End If
If e.Row.RowType = DataControlRowType.Footer Then
Dim LblTotal As Label = CType(e.Row.FindControl("LblTotal"), Label)
LblTotal.Text = sumTotal.ToString("N2")
End If
Next
End Sub
End Class
<asp:TemplateField HeaderText="Amount">
<EditItemTemplate>
<asp:TextBox ID="TextBox29" runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:Label ID="LblTotal" runat="server"></asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="LblAmount" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
ประวัติการแก้ไข 2017-08-31 11:43:13
Date :
2017-08-31 11:42:13
By :
Mixs
gridview ผมแปลงเป็น datatable ครับเพื่อแปลงค่าข้อมูลบางอันครับผม ก่อนหน้า gridview คือลูป insert ครับ
Code (VB.NET)
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
CellPadding="3" CellSpacing="2" Height="254px" style="text-align: center"
Width="774px">
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<Columns>
<asp:TemplateField HeaderText="LINE">
<ItemTemplate>
<asp:Label ID="lblLine" runat="server" Text='<%# Eval("UNPD_LINECon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox28" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DOC">
<ItemTemplate>
<asp:Label ID="lblDOC" runat="server" Text='<%# Eval("UNP_DOCCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox27" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="INVOICENO">
<ItemTemplate>
<asp:Label ID="lblInvoiceNo" runat="server" Text='<%# Eval("UNP_INV_NOCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox26" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="INVOICEDATE">
<ItemTemplate>
<asp:Label ID="lblInvoiceDate" runat="server"
Text='<%# Eval("UNP_INV_DATECon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox25" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SHIPDATE">
<ItemTemplate>
<asp:Label ID="lblShipDate" runat="server" Text='<%# Eval("UNP_SHP_DATECon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox24" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PORT OF DESTINATION">
<ItemTemplate>
<asp:Label ID="lblPortofDes" runat="server" Text='<%# Eval("UNP_PORTCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox23" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TRADETERM">
<ItemTemplate>
<asp:Label ID="lblTradeTerm" runat="server"
Text='<%# Eval("UNP_TRADE_TERMCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox22" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="MODE">
<ItemTemplate>
<asp:Label ID="lblMode" runat="server" Text='<%# Eval("UNP_MODECon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox21" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="BILLTO">
<ItemTemplate>
<asp:Label ID="lblBillTo" runat="server" Text='<%# Eval("UNP_BILLTOCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox20" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SHIPTO">
<ItemTemplate>
<asp:Label ID="lblShipto" runat="server" Text='<%# Eval("UNP_SHIPTOCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox19" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PROJECT">
<ItemTemplate>
<asp:Label ID="lblProject" runat="server" Text='<%# Eval("UNP_PROJECTCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox18" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CURRENCY">
<ItemTemplate>
<asp:Label ID="lblCurrency" runat="server" Text='<%# Eval("UNP_CURRENCYCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox17" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="REMARK">
<ItemTemplate>
<asp:Label ID="lblRemark" runat="server" Text='<%# Eval("UNP_REMARKCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox16" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DESCRIPTION2">
<ItemTemplate>
<asp:Label ID="lblDescription2" runat="server"
Text='<%# Eval("UNP_DESCRIPTION2Con") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox15" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DESCRIPTION1">
<ItemTemplate>
<asp:Label ID="lblDescription1" runat="server"
Text='<%# Eval("UNPD_DESCRIPTION1Con") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox14" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="FREIGHT">
<ItemTemplate>
<asp:Label ID="lblFreight" runat="server" Text='<%# Eval("UNP_FREIGHTCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox12" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="INSURANCE">
<ItemTemplate>
<asp:Label ID="lblInsurance" runat="server" Text='<%# Eval("UNP_INSURANCECon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox11" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="QUANTITY">
<ItemTemplate>
<asp:Label ID="lblQuantity" runat="server" Text='<%# Eval("UNPD_QTYCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="LIST PRICE">
<ItemTemplate>
<asp:Label ID="lblListPrice" runat="server"
Text='<%# Eval("UNPD_LIST_PRICECon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox9" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="UM">
<ItemTemplate>
<asp:Label ID="lblUm" runat="server" Text='<%# Eval("UNPD_UMCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PACKAGE">
<ItemTemplate>
<asp:Label ID="lblPackage" runat="server" Text='<%# Eval("UNPD_PACKAGECon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox8" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="NW">
<ItemTemplate>
<asp:Label ID="lblNw" runat="server" Text='<%# Eval("UNPD_NWCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="GW">
<ItemTemplate>
<asp:Label ID="lblGw" runat="server" Text='<%# Eval("UNPD_GWCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PER PACK">
<ItemTemplate>
<asp:Label ID="lblPerPack" runat="server" Text='<%# Eval("UNPD_PER_PACKCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DIMENSION">
<ItemTemplate>
<asp:Label ID="lblDimension" runat="server"
Text='<%# Eval("UNPD_DIMENSIONCon") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount">
<EditItemTemplate>
<asp:TextBox ID="TextBox29" runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:Label ID="LblTotal" runat="server"></asp:Label>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="LblAmount" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
</asp:GridView>
'Gridview
Dim dtGV As DataTable
Dim dtcon As DataTable = New DataTable()
Dim messageerror As String = ""
dtGV = GridImp(docnoGV)
If dtGV.Rows.Count > 0 Then
'....Headmstr.....
Dim UNP_FACTORYCon As String = ""
Dim UNP_DOCCon As String = ""
Dim UNP_REVCon As String = ""
Dim UNP_NSEQCon As String = ""
Dim STATUSCon As String = ""
Dim UNP_INV_NOCon As String = ""
Dim UNP_INV_DATECon As String = ""
Dim UNP_SHP_DATECon As String = ""
Dim UNP_PORTCon As String = ""
Dim UNP_TRADE_TERMCon As String = ""
Dim UNP_MODECon As String = ""
Dim UNP_BILLTOCon As String = ""
Dim UNP_BILL_ATTENTIONCon As String = ""
Dim UNP_SHIPTOCon As String = ""
Dim UNP_SHIP_ATTENTIONCon As String = ""
Dim UNP_SHIP_ATTENTION2Con As String = ""
Dim UNP_FORWARDERCon As String = ""
Dim UNP_ACCOUNTCon As String = ""
Dim UNP_PROJECTCon As String = ""
Dim UNP_CURRENCYCon As String = ""
Dim UNP_CASEMASKCon As String = ""
Dim UNP_REMARKCon As String = ""
Dim UNP_DESCRIPTION2Con As String = ""
Dim UNP_REQUESTERCon As String = ""
Dim UNP_COMMERCIALCon As String = ""
Dim UNP_FREIGHTCon As Double = 0
Dim UNP_INSURANCECon As Double = 0
Dim UNP_DOMAINCon As String = ""
Dim UNP_PURPOSECon As String = ""
Dim UNP_RE_IMPORTCon As String = ""
Dim UNP_RETURNCon As String = ""
Dim UNP_BOICon As String = ""
Dim UNP_REQ_PACKCon As String = ""
Dim UNP_INCLUDE_VATCon As String = ""
Dim USERCon As String = ""
'.....Detail....
Dim UNPD_LINECon As Integer = 0
Dim UNPD_DESCRIPTION1Con As String = ""
'Dim UNPD_ITEM_CODECon As String = ""
'Dim UNPD_INVCon As String = ""
'Dim UNPD_POCon As String = ""
Dim UNPD_CLAIM_NOCon As String = ""
'Dim UNPD_SERIAL_NOCon As String = ""
'Dim UNPD_ASSET_NOCon As String = ""
Dim UNPD_QTYCon As Double = 0
Dim UNPD_LIST_PRICECon As Double = 0
Dim UNPD_UMCon As String = ""
Dim UNPD_PACKAGECon As String = ""
Dim UNPD_NWCon As String = ""
Dim UNPD_GWCon As String = ""
Dim UNPD_PER_PACKCon As String = ""
Dim UNPD_DIMENSIONCon As String = ""
'Dim UNPD_PACK_DESCCon As String = ""
'Dim UNPD_NOBOICon As String = ""
'Dim UNPD_QTYBOICon As String = ""
'Dim UNPD_UMBOICon As String = ""
'....Headmstr......
Dim drcon As DataRow
dtcon.Columns.Add(New DataColumn("UNP_FACTORY", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_DOCCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_REVCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_NSEQCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("STATUSCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_INV_NOCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_INV_DATECon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_SHP_DATECon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_PORTCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_TRADE_TERMCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_MODECon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_BILLTOCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_BILL_ATTENTIONCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_SHIPTOCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_SHIP_ATTENTIONCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_SHIP_ATTENTION2Con", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_FORWARDERCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_ACCOUNTCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_PROJECTCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_CURRENCYCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_CASEMASKCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_REMARKCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_DESCRIPTION2Con", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_REQUESTERCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_COMMERCIALCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_FREIGHTCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_INSURANCECon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_DOMAINCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_PURPOSECon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_RE_IMPORTCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_RETURNCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_BOICon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_REQ_PACKCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNP_INCLUDE_VATCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("USERCon", GetType(String)))
'...Detail.....
'dtcon.Columns.Add(New DataColumn("UNP_FACTORYCon", GetType(String)))
'dtcon.Columns.Add(New DataColumn("UNP_DOCCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNPD_LINECon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNPD_DESCRIPTION1Con", GetType(String)))
'dtcon.Columns.Add(New DataColumn("UNPD_ITEM_CODECon", GetType(String)))
'dtcon.Columns.Add(New DataColumn("UNPD_INVCon", GetType(String)))
'dtcon.Columns.Add(New DataColumn("UNPD_POCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNPD_CLAIM_NOCon", GetType(String)))
'dtcon.Columns.Add(New DataColumn("UNPD_SERIAL_NOCon", GetType(String)))
'dtcon.Columns.Add(New DataColumn("UNPD_ASSET_NOCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNPD_QTYCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNPD_LIST_PRICECon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNPD_UMCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNPD_PACKAGECon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNPD_NWCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNPD_GWCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNPD_PER_PACKCon", GetType(String)))
dtcon.Columns.Add(New DataColumn("UNPD_DIMENSIONCon", GetType(String)))
'dtcon.Columns.Add(New DataColumn("UNPD_PACK_DESCCon", GetType(String)))
'dtcon.Columns.Add(New DataColumn("UNPD_NOBOICon", GetType(String)))
'dtcon.Columns.Add(New DataColumn("UNPD_QTYBOICon", GetType(String)))
'dtcon.Columns.Add(New DataColumn("UNPD_UMBOICon", GetType(String)))
For i As Integer = 0 To dtGV.Rows.Count - 1
'....Head......
UNPD_LINECon = dtGV.Rows(i).Item("UNPD_LINE")
'UNP_FACTORYCon = dtGV.Rows(i).Item("UNP_FACTORY")
UNP_DOCCon = dtGV.Rows(i).Item("UNP_DOC")
UNP_REVCon = dtGV.Rows(i).Item("UNP_REV")
UNP_NSEQCon = dtGV.Rows(i).Item("UNP_NSEQ")
STATUSCon = dtGV.Rows(i).Item("UNP_STAT_DET")
UNP_INV_NOCon = dtGV.Rows(i).Item("UNP_INV_NO")
UNP_INV_DATECon = dtGV.Rows(i).Item("UNP_INV_DATE")
UNP_SHP_DATECon = dtGV.Rows(i).Item("UNP_SHP_DATE")
UNP_PORTCon = dtGV.Rows(i).Item("UNP_PORT")
UNP_TRADE_TERMCon = dtGV.Rows(i).Item("UNP_TRADE_TERM")
UNP_MODECon = dtGV.Rows(i).Item("UNP_MODE")
UNP_BILLTOCon = dtGV.Rows(i).Item("UNP_BILLTO")
UNP_BILL_ATTENTIONCon = dtGV.Rows(i).Item("UNP_BILL_ATTENTION")
UNP_SHIPTOCon = dtGV.Rows(i).Item("UNP_SHIPTO")
UNP_SHIP_ATTENTIONCon = dtGV.Rows(i).Item("UNP_SHIP_ATTENTION")
UNP_SHIP_ATTENTION2Con = dtGV.Rows(i).Item("UNP_SHIP_ATTENTION2")
UNP_FORWARDERCon = dtGV.Rows(i).Item("UNP_FORWARDER")
UNP_ACCOUNTCon = dtGV.Rows(i).Item("UNP_ACCOUNT")
UNP_PROJECTCon = dtGV.Rows(i).Item("UNP_PROJECT")
UNP_CURRENCYCon = dtGV.Rows(i).Item("UNP_CURRENCY")
UNP_CASEMASKCon = dtGV.Rows(i).Item("UNP_CASEMASK")
UNP_REMARKCon = dtGV.Rows(i).Item("UNP_REMARK")
UNP_DESCRIPTION2Con = dtGV.Rows(i).Item("UNP_DESCRIPTION2")
UNP_REQUESTERCon = dtGV.Rows(i).Item("UNP_REQUESTER")
UNP_COMMERCIALCon = dtGV.Rows(i).Item("UNP_COMMERCIAL")
UNP_FREIGHTCon = dtGV.Rows(i).Item("UNP_FREIGHT")
UNP_INSURANCECon = dtGV.Rows(i).Item("UNP_INSURANCE")
UNP_DOMAINCon = dtGV.Rows(i).Item("UNP_DOMAIN")
UNP_PURPOSECon = dtGV.Rows(i).Item("UNP_PURPOSE")
UNP_RE_IMPORTCon = dtGV.Rows(i).Item("UNP_RE_IMPORT")
UNP_RETURNCon = dtGV.Rows(i).Item("UNP_RETURN")
UNP_BOICon = dtGV.Rows(i).Item("UNP_BOI")
UNP_REQ_PACKCon = dtGV.Rows(i).Item("UNP_REQ_PACK")
UNP_INCLUDE_VATCon = dtGV.Rows(i).Item("UNP_INCLUDE_VAT")
'....Detail......
'UNPD_LINECon = dtGV.Rows(i).Item("UNPD_LINE")
UNPD_DESCRIPTION1Con = dtGV.Rows(i).Item("UNPD_DESCRIPTION1")
'UNPD_ITEM_CODECon = dtGV.Rows(i).Item("UNPD_ITEM_CODE")
'UNPD_INVCon = dtGV.Rows(i).Item("UNPD_INV")
'UNPD_POCon = dtGV.Rows(i).Item("UNPD_PO")
UNPD_CLAIM_NOCon = dtGV.Rows(i).Item("UNPD_CLAIM_NO")
'UNPD_SERIAL_NOCon = dtGV.Rows(i).Item("UNPD_SERIAL_NO")
'UNPD_ASSET_NOCon = dtGV.Rows(i).Item("UNPD_ASSET_NO")
UNPD_QTYCon = dtGV.Rows(i).Item("UNPD_QTY")
UNPD_LIST_PRICECon = dtGV.Rows(i).Item("UNPD_LIST_PRICE")
UNPD_UMCon = dtGV.Rows(i).Item("UNPD_UM")
UNPD_PACKAGECon = dtGV.Rows(i).Item("UNPD_PACKAGE")
UNPD_NWCon = dtGV.Rows(i).Item("UNPD_NW")
UNPD_GWCon = dtGV.Rows(i).Item("UNPD_GW")
UNPD_PER_PACKCon = dtGV.Rows(i).Item("UNPD_PER_PACK")
UNPD_DIMENSIONCon = dtGV.Rows(i).Item("UNPD_DIMENSION")
'UNPD_PACK_DESCCon = dtGV.Rows(i).Item("UNPD_PACK_DESC")
'UNPD_NOBOICon2 = dtGV.Rows(i).Item("UNPD_NOBOI")
'UNPD_QTYBOICon2 = dtGV.Rows(i).Item("UNPD_QTYBOI")
'UNPD_UMBOICon2 = dtGV.Rows(i).Item("UNPD_UMBOI")
drcon = dtcon.NewRow()
Dim dtcon1 As DataTable = gPartofDescheck(UNP_PORTCon)
If dtcon1.Rows.Count > 0 Then
UNP_PORTCon = dtcon1.Rows.Item(0).Item("code_cmmt").ToString()
End If
Dim dtcon2 As DataTable = checkTrade1impcon(UNP_TRADE_TERMCon)
If dtcon2.Rows.Count > 0 Then
UNP_TRADE_TERMCon = dtcon2.Rows.Item(0).Item("code_cmmt").ToString()
End If
'....Head.....
drcon("UNPD_LINECon") = UNPD_LINECon
'drcon("UNP_FACTORYCon") = UNP_FACTORYCon
drcon("UNP_DOCCon") = UNP_DOCCon
'drcon("UNP_REVCon") = UNP_REVCon
'drcon("UNP_NSEQCon") = UNP_NSEQCon
'drcon("STATUSCon") = STATUSCon
drcon("UNP_INV_NOCon") = UNP_INV_NOCon
drcon("UNP_INV_DATECon") = UNP_INV_DATECon
drcon("UNP_SHP_DATECon") = UNP_SHP_DATECon
drcon("UNP_PORTCon") = UNP_PORTCon
drcon("UNP_TRADE_TERMCon") = UNP_TRADE_TERMCon
drcon("UNP_MODECon") = UNP_MODECon
drcon("UNP_BILLTOCon") = UNP_BILLTOCon
drcon("UNP_BILL_ATTENTIONCon") = UNP_BILL_ATTENTIONCon
drcon("UNP_SHIPTOCon") = UNP_SHIPTOCon
drcon("UNP_SHIP_ATTENTIONCon") = UNP_SHIP_ATTENTIONCon
drcon("UNP_SHIP_ATTENTION2Con") = UNP_SHIP_ATTENTION2Con
'drcon("UNP_FORWARDERCon") = UNP_FORWARDERCon
'drcon("UNP_ACCOUNTCon") = UNP_ACCOUNTCon
drcon("UNP_PROJECTCon") = UNP_PROJECTCon
drcon("UNP_CURRENCYCon") = UNP_CURRENCYCon
'drcon("UNP_CASEMASKCon") = UNP_CASEMASKCon
drcon("UNP_REMARKCon") = UNP_REMARKCon
drcon("UNP_DESCRIPTION2Con") = UNP_DESCRIPTION2Con
'drcon("UNP_REQUESTERCon") = UNP_REQUESTERCon
'drcon("UNP_COMMERCIALCon") = UNP_COMMERCIALCon
drcon("UNP_FREIGHTCon") = UNP_FREIGHTCon
drcon("UNP_INSURANCECon") = UNP_INSURANCECon
'drcon("UNP_DOMAINCon") = UNP_DOMAINCon
'drcon("UNP_PURPOSECon") = UNP_PURPOSECon
'drcon("UNP_RE_IMPORTCon") = UNP_RE_IMPORTCon
'drcon("UNP_RETURNCon") = UNP_RETURNCon
'drcon("UNP_BOICon") = UNP_BOICon
'drcon("UNP_REQ_PACKCon") = UNP_REQ_PACKCon
'drcon("UNP_INCLUDE_VATCon") = UNP_INCLUDE_VATCon
'drcon("USERCon") = USERCon
'....Detail......
'drcon = dtcon.NewRow()
'drcon("UNPD_LINECon") = UNPD_LINECon
drcon("UNPD_DESCRIPTION1Con") = UNPD_DESCRIPTION1Con
'drcon("UNPD_ITEM_CODECon") = UNPD_ITEM_CODECon
'drcon("UNPD_INVCon") = UNPD_INVCon
'drcon("UNPD_POCon") = UNPD_POCon
drcon("UNPD_CLAIM_NOCon") = UNPD_CLAIM_NOCon
'drcon("UNPD_SERIAL_NOCon") = UNPD_SERIAL_NOCon
'drcon("UNPD_ASSET_NOCon") = UNPD_ASSET_NOCon
drcon("UNPD_QTYCon") = UNPD_QTYCon
drcon("UNPD_LIST_PRICECon") = UNPD_LIST_PRICECon
drcon("UNPD_UMCon") = UNPD_UMCon
drcon("UNPD_PACKAGECon") = UNPD_PACKAGECon
drcon("UNPD_NWCon") = UNPD_NWCon
drcon("UNPD_GWCon") = UNPD_GWCon
drcon("UNPD_PER_PACKCon") = UNPD_PER_PACKCon
drcon("UNPD_DIMENSIONCon") = UNPD_DIMENSIONCon
'drcon("UNPD_PACK_DESCCon") = UNPD_PACK_DESCCon
'drcon("UNPD_NOBOICon") = UNPD_NOBOICon
'drcon("UNPD_QTYBOICon") = UNPD_QTYBOICon
'drcon("UNPD_UMBOICon") = UNPD_UMBOICon
dtcon.Rows.Add(drcon)
Next
Me.GridView1.DataSource = dtcon
GridView1.DataBind()
Else
GridView1.DataBind()
End If
ประวัติการแก้ไข 2017-08-31 13:56:28
Date :
2017-08-31 13:40:35
By :
Mixs
แก้ไขได้แล้วครับ ย้ายไปใส่ใน gridview แทนครับ
Code (VB.NET)
Dim sumTotal As Double
Dim sumQty As Double
For u As Integer = 0 To GridView1.Rows.Count - 1
Dim Qty1 As Double = DirectCast(GridView1.Rows(u).FindControl("lblQuantity"), Label).Text()
Dim Qty2 As Double = DirectCast(GridView1.Rows(u).FindControl("lblListPrice"), Label).Text()
Dim Qty3 As Label = DirectCast(GridView1.Rows(u).FindControl("lblAmount"), Label)
Dim Qty4 As Label = DirectCast(GridView1.FooterRow.FindControl("lblTotal"), Label)
sumQty = Qty1 * Qty2
Qty3.Text = FormatNumber(sumQty, 2)
sumTotal += CDbl(Qty3.Text)
Qty4.Text = sumTotal
Next
Date :
2017-08-31 15:39:35
By :
Mixs
Load balance : Server 05