开发者

Telerik GridViewDataControl - load from datatable

does anyone uses this control and know开发者_运维技巧s how to load data to it from simple datatable. There is not such a trick as DataSource...


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.


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)


We must use ItemsSource property like this:

dataGridView1.ItemsSource = LoadDataTable.DefaultView;

LoadDataTable - this is some DataTable, filled from SQL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜