Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > ขอโค้ด C# และ asp ในการคำนวณ DataGridView แบบ column



 

ขอโค้ด C# และ asp ในการคำนวณ DataGridView แบบ column

 



Topic : 055986



โพสกระทู้ ( 7 )
บทความ ( 0 )



สถานะออฟไลน์




คำนวณ


จากรูป ต้องการคำนวณ ราคาขายค่ะ โดย เอา (column 4 * column 5) = column 6

ขอโค้ด C# และ asp ค่ะ รบกวนผู้รู้ ด้วยค่ะ



Tag : .NET, Web (ASP.NET), C#







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-02-13 20:30:52 By : yaikam View : 3071 Reply : 5
 

 

No. 1



โพสกระทู้ ( 6 )
บทความ ( 0 )



สถานะออฟไลน์


Code
protected void dgv_Matdet_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { จำนวน= Convert.ToInt64(DataBinder.Eval(e.Row.DataItem, "fileจำนวน")); ราคา= Convert.ToSingle(DataBinder.Eval(e.Row.DataItem, "fileราคา")); modTotal = (Convert.ToSingle(ราคา) * (Convert.ToInt64(จำนวน))); e.Row.Cells[6].Text = modTotal.ToString("#,###.0"); } } }

ประมาณนี้ครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-02-13 21:47:23 By : SUKSANKIT
 


 

No. 2



โพสกระทู้ ( 7 )
บทความ ( 0 )



สถานะออฟไลน์


ได้แล้วค่ะ ขอบคุณค่ะที่ช่วย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-02-13 23:46:07 By : yaikam
 

 

No. 3



โพสกระทู้ ( 7 )
บทความ ( 0 )



สถานะออฟไลน์


ภาพ
รบกวนอีกนิดน่ะค่ะ ตอนนี้แสดงราคารวมในcolumn 6 ได้แล้ว แต่อยากให้แสดงราคารวมทั้งหมดใน Label2 โดยนำcolumn 6 มาบวกกันค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-02-14 01:41:17 By : yaikam
 


 

No. 4



โพสกระทู้ ( 6 )
บทความ ( 0 )



สถานะออฟไลน์


// สร้างขึ้นมาใน page function คำนวน
Code
public decimal TotalUnitPrice; public decimal GetUnitPrice(decimal Price) { TotalUnitPrice += Price; return Price; } public decimal GetTotal() { return TotalUnitPrice; }



<asp:GridView ID="grvDetail" runat="server" AutoGenerateColumns="False" ShowFooter ="True"
BackColor="White" BorderColor="Black" BorderStyle="Ridge" BorderWidth="1px"
CellPadding="3" DaCode
taKeyNames="id" OnRowCancelingEdit="modCancelCommand" OnRowCommand="grvDetail_RowCommand" OnRowDataBound="grvDetail_RowDataBound" OnRowDeleting="modDeleteCommand" OnRowEditing="modEditCommand" OnRowUpdating="modUpdateCommand" Width="100%" onselectedindexchanged="grvDetail_SelectedIndexChanged"> <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Center" /> <Columns> <asp:TemplateField HeaderImageUrl="~/Imagefiles/Delete.gif" HeaderText="ลบข้อมูล"> <ItemTemplate> <asp:CheckBox ID="cbxDelete" runat="server" ToolTip="ติกเพื่อลบข้อมูล" /> </ItemTemplate> <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /> </asp:TemplateField> <%-- //////////////////////////////////////////// --%> <asp:TemplateField HeaderText=" กะ "> <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <ItemStyle HorizontalAlign="Center" VerticalAlign="Top" /> <ItemTemplate> <asp:Label ID="lblShift" runat="server" Width ="50px" Text='<%# DataBinder.Eval(Container, "DataItem.shiftname") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="ddlEditShift" runat="server" AutoPostBack="True" CssClass="Bold_Pink"> </asp:DropDownList> </EditItemTemplate> </asp:TemplateField> <%-- //////////////////////////////////////////// --%> <asp:TemplateField HeaderText="ลำดับที่" > <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <ItemStyle HorizontalAlign="Center" VerticalAlign="Top" /> <ItemTemplate> <asp:Label ID="lblmatmixcount" runat="server" Width ="50px" Text='<%# DataBinder.Eval(Container, "DataItem.matmixcount") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="ddl_EditMatMixCount" runat="server" AutoPostBack="True" CssClass="Bold_Pink"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> <asp:ListItem>4</asp:ListItem> <asp:ListItem>5</asp:ListItem> <asp:ListItem>6</asp:ListItem> <asp:ListItem>7</asp:ListItem> <asp:ListItem>8</asp:ListItem> <asp:ListItem>9</asp:ListItem> <asp:ListItem>10</asp:ListItem> </asp:DropDownList> </EditItemTemplate> </asp:TemplateField> <%-- //////////////////////////////////////////// --%> <asp:TemplateField HeaderText="ID" SortExpression="id" Visible="false"> <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" /> <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <ItemTemplate> <asp:Label ID="lblid" runat="server" Text='<%# Bind("id") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <%-- //////////////////////////////////////////// --%> <asp:TemplateField HeaderText="ชื่อวัตถุดิบผสม" SortExpression="matname"> <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" /> <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <ItemTemplate> <asp:Label ID="lblmatname" runat="server" Text='<%# Bind("matname") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <%-- //////////////////////////////////////////// --%> <asp:TemplateField HeaderText="รหัสแผน" SortExpression="planid" Visible="false"> <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" /> <HeaderStyle HorizontalAlign="Center" VerticalAlign="Top" /> <ItemTemplate> <asp:Label ID="lblplanid" runat="server" Text='<%# Bind("planid") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <%-- //////////////////////////////////////////// --%> <asp:TemplateField HeaderText="ชื่อเครื่องจักร" SortExpression="MacName" Visible="false"> <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" /> <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <ItemTemplate> <asp:Label ID="lblMacName" runat="server" Text='<%# Bind("MacName") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <%-- //////////////////////////////////////////// --%> <asp:TemplateField HeaderText=" กะ " SortExpression="shiftid" Visible="false"> <ItemStyle HorizontalAlign="Center" VerticalAlign="Top" /> <HeaderStyle HorizontalAlign="Right" VerticalAlign="Middle" /> <ItemTemplate> <asp:Label ID="lblshiftname" runat="server" Text='<%# Bind("shiftid") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <%-- //////////////////////////////////////////// --%> <asp:TemplateField HeaderText="ประเภทวัตถุดิบ" FooterText="Total:" > <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <ItemStyle HorizontalAlign="Center" VerticalAlign="Top" Width="120px"/> <ItemTemplate> <asp:Label ID="lblTypeMatDetName" runat="server" Width="60px" Text='<%# DataBinder.Eval(Container, "DataItem.TypeMatDetName") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:DropDownList ID="ddlEditTypeMatDetName" runat="server" AutoPostBack="True" CssClass="Bold_Pink"> </asp:DropDownList> </EditItemTemplate> </asp:TemplateField> <%-- //////////////////////////////////////////// --%> <asp:TemplateField HeaderText="รหัสเครื่องจักร" SortExpression="MacID" Visible="false"> <ItemStyle HorizontalAlign="Center" VerticalAlign="Top" /> <HeaderStyle HorizontalAlign="Right" VerticalAlign="Top" /> <ItemTemplate> <asp:Label ID="lblMacID" runat="server" Text='<%# Bind("MacID") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="ชื่อวัตถุดิบผสม" SortExpression="MatID" Visible="false"> <ItemStyle HorizontalAlign="Center" VerticalAlign="Top" /> <HeaderStyle HorizontalAlign="Right" VerticalAlign="Middle" /> <ItemTemplate> <asp:Label ID="lblMatID" runat="server" Text='<%# Bind("MatID") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="จำนวน kg" SortExpression="MatMixKg"> <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" /> <ItemTemplate> <asp:Label ID="lblMatMixKg" runat="server" Width="100px" Text='<%# GetUnitPrice(decimal.Parse(Eval("MatMixKg").ToString())).ToString("N2")%>'> </asp:Label> </ItemTemplate> <FooterTemplate> <%# lbltotal.Text = GetTotal().ToString("N2")%> ตรงบันทัดนี้เอา lbltotal.Text = ออกก็จะได้ผลรวมในgrid ครับ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; </FooterTemplate> <FooterStyle Font-Bold="True" HorizontalAlign="Right" /> <ItemStyle HorizontalAlign="Center" Width="120px" /> </asp:TemplateField> </Columns> <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" HorizontalAlign="Right" Font-Bold="true" Height="30px" /> <AlternatingRowStyle BackColor="White" /> <HeaderStyle CssClass ="H_Orange" /> </asp:GridView>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-02-16 06:54:46 By : SUKSANKIT
 


 

No. 5

Guest


ขอโค้ด C#หน่อยครับ
พอดีต้องการโค้ดในส่วนนี้เหมือนกัน
รบกวนด้วยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-08-14 12:30:29 By : Gust
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ขอโค้ด C# และ asp ในการคำนวณ DataGridView แบบ column
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่