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

[Solved] How to Implement this

1 Answer 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Waleed Seada
Top achievements
Rank 2
Waleed Seada asked on 12 Dec 2009, 06:11 PM
Dear All,

I have a radgrid on one of my UserControls that I need to display data.
1: Data grid needs to show three columns with no data when the usercontrol is loaded.
I put this code in the page_load of the usercontrol:
DataTable dt = new DataTable();  
dt.Columns.Add("Source"typeof(string));  
dt.Columns.Add("Value"typeof(string));  
IdentifiersGrid.DataSource = dt; 
BUT the grid doesn't show anything when loaded, If I put the previous code in the Need_DataSource event it shows the columns.

2: I have a button on the usercontrol that will fill the grid with data, where I create a datatable and fill with data as follows:
dt.Rows.Add(ids[0].Value, ids[1].Value); 
I get an exception "Input array is longer than the number of columns in this table."

What is wrong with this, can someone help

Best regards
Waleed

1 Answer, 1 is accepted

Sort by
0
Waleed Seada
Top achievements
Rank 2
answered on 12 Dec 2009, 06:48 PM
Sorry Guys for any inconvenience

Just figure out that I need to add the columns to the datatable first.


Waleed
Tags
Grid
Asked by
Waleed Seada
Top achievements
Rank 2
Answers by
Waleed Seada
Top achievements
Rank 2
Share this question
or