Gridview DataSource Selection [Resolved]

Posted by Rasagna under ASP.NET on 12/29/2015 | Points: 10 | Views : 1522 | Status : [Member] | Replies : 2
Why do we need to fill Gridview by using Datatable or Dataset when there is an option in gridview where we can use choose datasource option directly and select the datasource.




Responses

Posted by: Sheonarayan on: 12/29/2015 [Administrator] HonoraryPlatinum | Points: 50

Up
0
Down

Resolved
I think when you say "we can use choose datasource option directly and select the datasource. " you mean, you can do it in design view or directly in .aspx page.

When you work with the design view, you have very limited ability to play with (manipulate) the data source. In this case you might not be following the any architecture (like 3 tier). You will have to depend on another ASP.NET Server control like SqlDataSource control or XmlDataSource control.

When you set the DataTable or DataSet as data source in the code behind file, you have complete control over it. You might be writing the data access code in another layer and calling that method in UI layer (read 3-tier architecture implementation and benefit - http://www.dotnetfunda.com/articles/show/2708/3-tier-architecture-in-aspnet-a-complete-article) .

However, you have a asp:ObjectDataSource where you can use methods of code behind to populate the data into GridView, however that is not easy and straight forward as setting the data source directly from the code behind.

So you can say, it's matter of preference and how comfortable you feel. I personally, do not use .aspx / or design view to set the data source. Particularly for GridView as it is data intensive control.

Hope this answer your question.

Thanks


Regards,
Sheo Narayan
http://www.dotnetfunda.com

Rasagna, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rasagna on: 12/29/2015 [Member] Starter | Points: 25

Up
0
Down
@Sheonarayan, thanks for making it clear..

Rasagna, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response