G
Guest
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();
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();