tags:

views:

117

answers:

3

Hello, does anyone uses this control and knows how to load data to it from simple datatable. There is not such a trick as DataSource...

A: 

Im assuming you just mean a datatable you have created programatically?

It will bind straight up like it would from a DataSource.

Just make sure your DataField name in the columns mark up matches the name of the column and your good to go, just as you would with a different datasource.

Then just do

grvFoo.DataSource = yourProgrammticallyCreatedTable;
grvFoo.DataBind();

But, since your doing this progrmatically I would recommend making a "BindTable" function. Eg a function that builds your datatable and bind. You can then use this for sorting / paging etc. As your doing this all programatically you must handle such events by hand, they are normally done with the SQL / Object Datasource etc.

Jammin
A: 

you mean Telerik Radgrid ? If yes, you can also specify a "NeedDataSource" event in the aspx/ascx

http://www.telerik.com/help/aspnet-ajax/grdadvanceddatabinding.html

On a side note, just to let you know, we are having a lot of performance problems with Telerik. For the most part, you can use the inbuilt asp.net gridview (and do some more styling if needed) than taking a performance hit by using telerik (for their fancy grid)

ram
A: 

We must use ItemsSource property like this:

dataGridView1.ItemsSource = LoadDataTable.DefaultView;

LoadDataTable - this is some DataTable, filled from SQL.

Vytas999