This is a migrated thread and some comments may be shown as answers.

Problem with DataBinding

3 Answers 89 Views
GridView
This is a migrated thread and some comments may be shown as answers.
first name
Top achievements
Rank 1
first name asked on 06 Aug 2008, 01:34 PM
Hi,

I have problem with databinding for next table:
------------------------------------------------------------
 DataTable table = new DataTable();
 table.Columns.Add("i.[InvoiceNumber]", typeof(string));
 table.Columns.Add("fncd.[CustomerNumber]", typeof(string));
 table.Columns.Add("fncd.[eBayBuyerID]", typeof(string));
 table.Columns.Add("fncd.[FirstName]", typeof(string));
 table.Columns.Add("fncd.[LastName]", typeof(string));
 table.Columns.Add("fncd.[ItemQTY]", typeof(int));
 table.Columns.Add("ist.[Description]", typeof(string));
 table.Columns.Add("i.[NetTotalAmount]", typeof(decimal));
 table.Columns.Add("i.[VATTotalAmount]", typeof(decimal));
 table.Columns.Add("i.[GrossTotalAmount]", typeof(decimal));
 table.Columns.Add("i.[InvoiceDate]", typeof(DateTime));

table.Rows.Add("INV0001", "CUS0001", "0", "And", "Tar", 2, "Deccriptio", 10, 2, 12, DateTime.Now);
            table.Rows.Add("INV0002", "CUS0002", "1", "And", "Tar", 2, "Deccriptio", 10, 2, 12, DateTime.Now);
            table.Rows.Add("INV0003", "CUS0003", "2", "And", "Tar", 2, "Deccriptio", 10, 2, 12, DateTime.Now);

radGridView1.DataSource = table;
-----------------------------------------------------------------------

when i ran this i see 3 rows in grid but all cells is empty(nothing data to display).
thanks.

3 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 07 Aug 2008, 09:08 AM
Hi,

The problem is the syntax that you have used for sub properties in DataTable column name. For your scenario you can use following code snippet:

DataTable table = new DataTable(); 
table.Columns.Add("[InvoiceNumber]"typeof(string)); 
table.Columns.Add("[CustomerNumber]"typeof(string)); 
table.Columns.Add("[eBayBuyerID]"typeof(string)); 
table.Columns.Add("[FirstName]"typeof(string)); 
table.Columns.Add("[LastName]"typeof(string)); 
table.Columns.Add("[ItemQTY]"typeof(int)); 
table.Columns.Add("[Description]"typeof(string)); 
table.Columns.Add("[NetTotalAmount]"typeof(decimal)); 
table.Columns.Add("[VATTotalAmount]"typeof(decimal)); 
table.Columns.Add("[GrossTotalAmount]"typeof(decimal)); 
table.Columns.Add("[InvoiceDate]"typeof(DateTime)); 
 
table.Rows.Add("INV0001""CUS0001""0""And""Tar", 2, "Deccriptio", 10, 2, 12, DateTime.Now); 
table.Rows.Add("INV0002""CUS0002""1""And""Tar", 2, "Deccriptio", 10, 2, 12, DateTime.Now); 
table.Rows.Add("INV0003""CUS0003""2""And""Tar", 2, "Deccriptio", 10, 2, 12, DateTime.Now); 
 
radGridView1.DataSource = table; 

Don't hesitate to contact us if you have other questions. 

All the best,
Julian Benkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
first name
Top achievements
Rank 1
answered on 07 Aug 2008, 09:15 AM
Hi,
Thanks for answer, but i get this table from store procedure and cannot use other syntax. standard System.WIndows.Forms.DataGridView accept this syntax.


0
Julian Benkov
Telerik team
answered on 08 Aug 2008, 09:49 AM
Hello First Name,

The standard System.WIndows.Forms.DataGridView accept this syntax, but binding to sub properties is not supported. But our RadGridView control supports this feature. In this situation you must remove the point symbol from column names for the table object.

In our future release we will include a property for enabling/disabling sub properties binding in RadGridView.


All the best,
Julian Benkov
the Telerik team


Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
first name
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
first name
Top achievements
Rank 1
Share this question
or