All I'm doing, is using the Compute Method and getting the Sum of the Amount
field in my SQL Query. The problem is getting the Data Table to add a Column
and put the total in the "Total Column". I can see that I'm getting the data
I want, But can not display it. I could sure use the Help.
Thanks In Advance
THE CODE:
SqlDataAdapter da = new SqlDataAdapter();
DataSet ds = new DataSet();
this.sqlConnection1.Open();
da.SelectCommand=scmd;
da.Fill(ds,"Global");
DataGridTableStyle tsl = new DataGridTableStyle();
DataGridColumnStyle TextCol = new DataGridTextBoxColumn();
TextCol.MappingName = "First";
TextCol.HeaderText = "First";
TextCol.Width = 150;
DataGridColumnStyle COL = new DataGridTextBoxColumn();
COL.MappingName = "Last";
COL.HeaderText = "Last";
COL.Width = 150;
DataGridColumnStyle MI = new DataGridTextBoxColumn();
MI.MappingName = "MI";
MI.HeaderText = "MI";
MI.Width = 25;
DataGridColumnStyle Address = new DataGridTextBoxColumn();
Address.MappingName = "Address";
Address.HeaderText = "Address";
Address.Width = 150;
DataGridColumnStyle Total = new DataGridTextBoxColumn();
Total.MappingName = ds.Tables["Global"].Compute("Sum(Amount)","Amount >
0").ToString();
Total.HeaderText = "Total";
Total.Width = 25;
tsl.MappingName="Global";
tsl.GridColumnStyles.Add(TextCol);
tsl.GridColumnStyles.Add(COL);
tsl.GridColumnStyles.Add(Total);
tsl.GridColumnStyles.Add(MI);
tsl.GridColumnStyles.Add(Address);
tsl.GridColumnStyles.Add(Total);
dgSummary.DataSource=ds;
dgSummary.DataMember="Global";
dgSummary.TableStyles.Add(tsl);
this.sqlConnection1.Close();
W.G. Ryan eMVP - 29 Oct 2004 23:38 GMT
Where are you adding the DataColumn? If you add the column to the Columns
collection and then just map a COlumnstyle to it, it should show
http://www.knowdotnet.com/articles/expressions.html
However compute works on aggregates so I'm not sure if you want the Total in
each column.

Signature
W.G. Ryan, MVP
www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
> All I'm doing, is using the Compute Method and getting the Sum of the Amount
> field in my SQL Query. The problem is getting the Data Table to add a Column
[quoted text clipped - 49 lines]
> dgSummary.TableStyles.Add(tsl);
> this.sqlConnection1.Close();