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

Grid on Page_Init and NeedDataSource Event

4 Answers 190 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manuel Ortiz
Top achievements
Rank 1
Manuel Ortiz asked on 03 Apr 2010, 06:10 PM
Hi, I have a dynamically created grid on page_init as you show in your demos.  I would like to know if there is any difference between setting the Grid.DataSource when the Grid is created on Page_Init and setting the DataSource on the NeedDataSource event of the grid.  I ask this because I noticed that the grid always calls the NeedDataSource event as opposed to if the grid was created declaratively in the page.

Any help would be greatly appreciated,
Manuel

4 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 06 Apr 2010, 03:45 PM
Hi Manuel,

Our examples on Simple databinding and Advanced databinding and the related help topics should contain the answer for your.

Hope it helps.

Best wishes,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
s
Top achievements
Rank 1
answered on 18 Jul 2011, 11:12 AM
Hi 
i have used radgrid controls in my vb.net project. Now im modifying my code and using gridview instead of radgrid controls.
but there is an event "NeedDataSource" for radgrid control. Now my doubt is , which event do i need to use for this "NeedDataSource" in gridview events.

Regards,
Sam
0
Princy
Top achievements
Rank 2
answered on 18 Jul 2011, 11:38 AM
Hello Samantha,

In GridView you can populate the grid using SimpleDataBinding and then call the DataBind method on the first page load or after any data operation. On the other hand, NeedDataSource event fires each time when RadGrid needs to be bound to a data source. Hope this helps.

Thanks,
Princy.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 18 Jul 2011, 11:42 AM
Hi Sam,

There is not any similar event ("NeedDataSource") available for GridView.

Only RadGrid have "NeedDataSource" event and this event you can assign Datasource to RadGrid.

Advantage of this event is user can assign only one time assign a DataSource to RadGrid and RadGrid called this event after (Sorting ,Pagging,Filter..etc.) automatically.

If we need to call this event explicitly then we call by this "RadGrid.Rebind();"

http://www.telerik.com/help/aspnet/grid/radgrid-telerik.webcontrols.radgrid-needdatasource_ev.html

http://www.telerik.com/help/aspnet/grid/grdcommandsthatinvokerebindimplicitly.html

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Manuel Ortiz
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
s
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Jayesh Goyani
Top achievements
Rank 2
Share this question
or