473,672 Members | 2,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't insert a Column in DataGrid which DataSet does not Contain

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.sqlConnect ion1.Open();
da.SelectComman d=scmd;
da.Fill(ds,"Glo bal");

DataGridTableSt yle tsl = new DataGridTableSt yle();
DataGridColumnS tyle TextCol = new DataGridTextBox Column();
TextCol.Mapping Name = "First";
TextCol.HeaderT ext = "First";
TextCol.Width = 150;

DataGridColumnS tyle COL = new DataGridTextBox Column();
COL.MappingName = "Last";
COL.HeaderText = "Last";
COL.Width = 150;
DataGridColumnS tyle MI = new DataGridTextBox Column();
MI.MappingName = "MI";
MI.HeaderText = "MI";
MI.Width = 25;

DataGridColumnS tyle Address = new DataGridTextBox Column();
Address.Mapping Name = "Address";
Address.HeaderT ext = "Address";
Address.Width = 150;

DataGridColumnS tyle Total = new DataGridTextBox Column();
Total.MappingNa me = ds.Tables["Global"].Compute("Sum(A mount)","Amount >
0").ToString ();
Total.HeaderTex t = "Total";
Total.Width = 25;

tsl.MappingName ="Global";

tsl.GridColumnS tyles.Add(TextC ol);
tsl.GridColumnS tyles.Add(COL);
tsl.GridColumnS tyles.Add(Total );
tsl.GridColumnS tyles.Add(MI);
tsl.GridColumnS tyles.Add(Addre ss);
tsl.GridColumnS tyles.Add(Total );

dgSummary.DataS ource=ds;
dgSummary.DataM ember="Global";
dgSummary.Table Styles.Add(tsl) ;
this.sqlConnect ion1.Close();
Jul 21 '05 #1
1 2203
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.

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"Terry" <Te***@discussi ons.microsoft.c om> wrote in message
news:8F******** *************** ***********@mic rosoft.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 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.sqlConnect ion1.Open();
da.SelectComman d=scmd;
da.Fill(ds,"Glo bal");

DataGridTableSt yle tsl = new DataGridTableSt yle();
DataGridColumnS tyle TextCol = new DataGridTextBox Column();
TextCol.Mapping Name = "First";
TextCol.HeaderT ext = "First";
TextCol.Width = 150;

DataGridColumnS tyle COL = new DataGridTextBox Column();
COL.MappingName = "Last";
COL.HeaderText = "Last";
COL.Width = 150;
DataGridColumnS tyle MI = new DataGridTextBox Column();
MI.MappingName = "MI";
MI.HeaderText = "MI";
MI.Width = 25;

DataGridColumnS tyle Address = new DataGridTextBox Column();
Address.Mapping Name = "Address";
Address.HeaderT ext = "Address";
Address.Width = 150;

DataGridColumnS tyle Total = new DataGridTextBox Column();
Total.MappingNa me = ds.Tables["Global"].Compute("Sum(A mount)","Amount >
0").ToString ();
Total.HeaderTex t = "Total";
Total.Width = 25;

tsl.MappingName ="Global";

tsl.GridColumnS tyles.Add(TextC ol);
tsl.GridColumnS tyles.Add(COL);
tsl.GridColumnS tyles.Add(Total );
tsl.GridColumnS tyles.Add(MI);
tsl.GridColumnS tyles.Add(Addre ss);
tsl.GridColumnS tyles.Add(Total );

dgSummary.DataS ource=ds;
dgSummary.DataM ember="Global";
dgSummary.Table Styles.Add(tsl) ;
this.sqlConnect ion1.Close();

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
447
by: John Latten | last post by:
Hi there, I have got a problem when adding extra (= dummy) columns to a datagrid. I have a datagrid that is bound to a datatable. The datatable is filled with data from a SQL Server 2000 database. This data contains a column that is a foreign key to another table. In my datagrid I don't want to display this keyvalue. Instead I want to use this key to get a description out of another table. I have added an extra column to both the...
2
1428
by: PaulNaude | last post by:
VB.NET 2003 I am battling with a specific procedure that does not allow me to update my data adapter due to an apparent syntax error. I created the data adapter usign the drag and drop method (from the Server Explorer to the form) by dragging the table in question to the form and then generating the dataset. In a procedure I add records to the problem table based on values in other datagrids in the following way:
10
3079
by: Robert Schuldenfrei | last post by:
Hi NG: I have the following code working. The GetProdStrtList() returns a DataTable called psTable. A Grid control is successfully bound to this table and displays correctly. I would like to change the column headings to something other than the name of SQL column. For example I would prefer "Component" to the default "ps_component". I would also like to set the column width property myself. As you can see, I can set the grid's...
0
10844
by: a | last post by:
I've read and split a delimited text file into a dataset. It looks fine in a datagrid (5 columns and 5,000 rows), but I've been trying, without success, to then insert the resulting dataset called "result" into a single sql table that has an auto-increment and PK column called ID, as well as the 5 columns from the dataset. Any suggestions on a way to perform the insert of the "result" dataset into the sql table?
6
5063
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I do with the 1st column ? (Below I have a "1" in place for now). Also, Does the datase.AcceptChanges(); updates the changes to the database? Which command do I use to update the changes in dataset back to the Access database table? Thanks, Alpha...
0
1766
by: Jim Hammond | last post by:
The code below implements two datagrid columns that display images. The first column is just a test that always displays the same image directly from a file. The second column pulls the image from the dataset. The datagrid contains several additional columns that are not seen here because they are automatically generated and bound to the dataset. All columns work except the second image column, which attempts to bind to the dataset. When...
1
1450
by: louise raisbeck | last post by:
This sounds complicated but bear with me. I have a datagrid. It is dynamic in that, i dont know how many columns i will have until the dataset is back so i have to build the datagrid dynamically. I know there will be at least one column required however, so I have put into my aspx a template column with a checkbox in it. Then for the number of columns in my dataset more than 1 I want to copy that templatecolumn and duplicate it for the...
1
219
by: Terry | last post by:
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();
6
2938
by: insirawali | last post by:
Hi all, I have this problem, i need to know is there a way i cn use the data adapter's update method in this scenario. i have 3 tables as below create table table1{ id1 int identity(1,1) Constraint pk_table1 Primary Key,
0
8932
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8832
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8611
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7449
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6240
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5709
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2067
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1819
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.