User1152553138 posted
Everyone are awaare of Gridview Helper Class ... See Below
https://www.agrinei.com/gridviewhelper/gridviewhelper_en.htm
The Gridview Helper SUM works only for Asp.Net GridView BoundField and it is not working in ItemTemplate ...
See Below Example BoundField
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" EnableViewState="False" DataKeyNames="OrderId" CellPadding="3">
<Columns>
<asp:BoundField DataField="ShipRegion" HeaderText="ShipRegion" SortExpression="ShipRegion" />
<asp:BoundField DataField="ShipName" HeaderText="ShipName" SortExpression="ShipName" />
<asp:BoundField DataField="OrderId" HeaderText="OrderId" InsertVisible="False" ReadOnly="True"
SortExpression="OrderId" />
<asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />
<asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" >
<ItemStyle HorizontalAlign="Right" />
</asp:BoundField>
<asp:BoundField DataField="UnitPrice" DataFormatString="{0:c}" HeaderText="UnitPrice"
HtmlEncode="False" SortExpression="UnitPrice" >
<ItemStyle HorizontalAlign="Right" />
</asp:BoundField>
<asp:BoundField DataField="ItemTotal" DataFormatString="{0:c}" HeaderText="ItemTotal"
HtmlEncode="False" ReadOnly="True" SortExpression="ItemTotal" >
<ItemStyle HorizontalAlign="Right" />
</asp:BoundField>
</Columns>
</asp:GridView>
<asp:Button ID="Button1" runat="server" Text="North" onclick="Button1_Click" />
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
GridViewHelper helper = new GridViewHelper(this.GridView1);
helper.RegisterGroup("ShipRegion", true, true);
helper.RegisterSummary("ItemTotal", SummaryOperation.Sum, "ShipRegion");
}
private void GridBind()
{
String strConnString = ConfigurationManager.ConnectionStrings["NorthWind"].ConnectionString;
SqlConnection con = new SqlConnection(strConnString);
SqlCommand cmd12 = new SqlCommand("Select ShipRegion, ShipName, Orders.OrderId, ProductName, Quantity, Products.UnitPrice, (Quantity * Products.UnitPrice) as ItemTotal from Orders, [Order Details], Products where Orders.OrderId = [Order Details].OrderId and [Order Details].ProductId = Products.ProductId and ShipRegion is not null and ShipCountry in ('Brazil') and year(OrderDate) = 1998 and month(OrderDate) = 3 ", con);
SqlDataAdapter da = new SqlDataAdapter(cmd12);
DataTable table = new DataTable();
da.Fill(table);
GridView1.DataSource = table;
GridView1.DataBind();
GridView1.Visible = true;
}
protected void Button1_Click(object sender, EventArgs e)
{
GridBind();
}
I tried using Item template field its not working ... Help here ... Please ...