<asp:GridView ID="GridView1" runat="server" DataKeyNames="id" CssClass="table table-striped" AutoGenerateColumns="False" HorizontalAlign="Center" ShowFooter="true" OnRowDataBound="GridView1_RowDataBound" FooterStyle-ForeColor="Maroon" FooterStyle-Font-Bold="true" FooterStyle-Font-Underline="true"> <Columns> <asp:TemplateField ItemStyle-Height="20" HeaderText="BIL."> <ItemTemplate> <%# Container.DataItemIndex + 1 %> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Company ID" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" Visible="false"> <ItemTemplate> <asp:Label ID="CompLbl" runat="server" Text='<%# Eval("CompId") %>' ForeColor="Maroon" Style="font-size: 12px;"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Date" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"> <ItemTemplate> <asp:Label ID="DateLbl" runat="server" Text='<%# Eval("OrderDate") %>' ForeColor="Maroon" Style="font-size: 12px;"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Order No" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"> <ItemTemplate> <asp:Label ID="DateLbl" runat="server" Text='<%# Eval("OrdNo") %>' ForeColor="Maroon" Style="font-size: 12px;"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Products" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"> <ItemTemplate> <asp:Label ID="MealLbl" runat="server" Text='<%# Eval("Product").ToString().Replace("%0a","<br />").Replace("|","<br />").Replace(Environment.NewLine,"<br />") %>' ForeColor="Maroon" Style="font-size: 12px;"></asp:Label> </ItemTemplate> <FooterTemplate> <asp:Label ID="TotalLbl" runat="server" Font-Bold="true" Text="Total" /> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Daily Total (RM)" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"> <ItemTemplate> <%--<asp:TextBox ID="txtTotal" runat="server" Text='<%# Eval("Total") %>' ForeColor="Maroon"></asp:TextBox>--%> <asp:Label ID="lblTotal" runat="server" Text='<%# Eval("Total") %>'></asp:Label> </ItemTemplate> <FooterTemplate> <asp:Label ID="lblTotalqty" runat="server" Font-Bold="true" /> </FooterTemplate> </asp:TemplateField> </Columns> <EmptyDataTemplate> No Record Found....!!! </EmptyDataTemplate> </asp:GridView>
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { decimal TotalSales = (decimal)0.0; if (e.Row.RowType == DataControlRowType.DataRow) { //TextBox mytotsale = (TextBox)e.Row.FindControl("txtTotal"); Label mytotsale = (Label)e.Row.FindControl("lblTotal"); if (mytotsale.Text != null) { int startIndex = 2; int endIndex = mytotsale.Text.Length - startIndex; string NewTotSales = mytotsale.Text.Substring(startIndex, endIndex); TotalSales += Convert.ToDecimal(NewTotSales); } } if (e.Row.RowType == DataControlRowType.Footer) { Label lblSum1 = (Label)e.Row.FindControl("lblTotalqty"); lblSum1.Text = TotalSales.ToString("C2"); } }
totsale
0
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)