Hi,
Summary values are not showing up in footer, please help. sample code listed below.
wbgdata1.Behaviors.CreateBehavior<SummaryRow>();
this.wbgdata1.Columns[1].Footer.Text = "Totals:";
//Summary Footer for Cartons
SummaryRowSetting BNCartonsSummary = new SummaryRowSetting(wbgdata1, "DDCARG");
BNCartonsSummary.ShowSummaryButton = false;
BNCartonsSummary.SummarySettings.Add(SummaryType.Sum);
this.wbgdata1.Behaviors.SummaryRow.ColumnSettings.Add(BNCartonsSummary);
wbgdata1.ShowFooter = true;
Thanks.
Hello,
The unbound field is not bound to anything its type should be specified explicitly. The default type is string and should be changed to numeric type by using the DataType property.
The updated version of GetData Method:
public void GetData(){ DataTable tblShipment = new DataTable("Shipment"); tblShipment.Columns.Add(new DataColumn("NumOfCartons", typeof(int))); UnboundField col = new UnboundField(); col.Key = "NumOfCartons"; col.Header.Text = "NumOfCartons"; col.DataType = "System.Int32"; this.WebDataGrid1.Columns.Add(col); DataRow r = tblShipment.NewRow(); r["NumOfCartons"] = 30; tblShipment.Rows.Add(r); WebDataGrid1.DataSource = tblShipment; //Bind the Dataset to the web grid WebDataGrid1.DataBind();}
public void GetData(){ DataTable tblShipment = new DataTable("Shipment"); tblShipment.Columns.Add(new DataColumn("NumOfCartons", typeof(int)));
UnboundField col = new UnboundField(); col.Key = "NumOfCartons"; col.Header.Text = "NumOfCartons"; col.DataType = "System.Int32"; this.WebDataGrid1.Columns.Add(col);
DataRow r = tblShipment.NewRow(); r["NumOfCartons"] = 30; tblShipment.Rows.Add(r); WebDataGrid1.DataSource = tblShipment; //Bind the Dataset to the web grid WebDataGrid1.DataBind();}
Let me know if you need further assistance on this.
Please see the sample code that produces the error.
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Infragistics.Web.UI.GridControls;
namespace WebApplication4
{
public partial class WebForm1 : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
GetData();
FooterValues();
}
public void FooterValues()
this.WebDataGrid1.Columns[0].Footer.Text = "Totals:";
WebDataGrid1.Behaviors.CreateBehavior<SummaryRow>();
ColumnSummaryInfo CartonsSummary = new ColumnSummaryInfo();
CartonsSummary.ColumnKey = "NumOfCartons";
CartonsSummary.Summaries.Add(SummaryType.Sum);
WebDataGrid1.Behaviors.SummaryRow.ColumnSummaries.Add(CartonsSummary);
SummaryRowSetting CartonsSummary1 = new SummaryRowSetting(WebDataGrid1, "Department");
CartonsSummary1.ShowSummaryButton = false;
this.WebDataGrid1.Behaviors.SummaryRow.ColumnSettings.Add(CartonsSummary1);
public void GetData()
DataTable tblShipment = new DataTable("Shipment");
tblShipment.Columns.Add(new DataColumn("NumOfCartons", typeof(int)));
UnboundField col = new UnboundField();
col.Key = "NumOfCartons";
col.Header.Text = "NumOfCartons";
this.WebDataGrid1.Columns.Add(col);
DataRow r = tblShipment.NewRow();
r["NumOfCartons"] = 30;
tblShipment.Rows.Add(r);
WebDataGrid1.DataSource = tblShipment;
//Bind the Dataset to the web grid
WebDataGrid1.DataBind();
Denis,
Could you please put together a sample with Webdatagrid where the columns are created manually with the summary data showing in footer values?.
Thanks for your help.
Srini
Based upon the error message provided it appears that you are trying to set a string to SummaryRowSetting. I may be able to investigate this further if you provide runnable isolated sample replicating the issue.
Looking forward for your sample.
More details as listed below.
I am getting the error "cannot convert from infragistics.web.ui.gridcontrols.summaryrowsetting to string". Column is defined as integer, not sure why I am getting this error.
ColumnSummaryInfo BNCartonsSummary1 = new ColumnSummaryInfo();
BNCartonsSummary1.ColumnKey = "DDCARG";
BNCartonsSummary1.Summaries.Add(SummaryType.Sum);
wbgdata1.Behaviors.SummaryRow.ColumnSummaries.Add(BNCartonsSummary1);
Columns are added manually as listed below:tblShipment = new DataTable("Shipment");tblShipment.Columns.Add(new DataColumn("Cartons", typeof(int)));
tc = wbgdata1.Columns["DDCARG"] as TemplateDataField;
if (tc == null)
{tc = new TemplateDataField();
tc.Key = "DDCARG";
tc.ItemTemplate = new PlaceHolderTemplate();
this.wbgdata1.Columns.Add(tc);
Please help.