Last post May 23, 2017 09:28 AM by Zhi Lv - MSFT
May 19, 2017 09:49 AM|maverick786us|LINK
Can someone show me a sample where a grid is bind with an objectdatasource and that object data source is calling the handler function and some parameters?
May 19, 2017 11:22 PM|RDowdall|LINK
I think this article may get you started in the right direction: http://highoncoding.com/Articles/139_GridView_With_ObjectDataSource.aspx
May 20, 2017 05:51 AM|maverick786us|LINK
Thanks for the help. This is how my source code looks like...
<asp:GridView ID="grdCustomers" runat="server" DataSourceID="objEnumerateCustomers">
<PagerStyle HorizontalAlign="Left" />
<asp:ObjectDataSource ID="objEnumerateCustomers" runat="server" SelectMethod="EnumerateCustomers" TypeName="QDC.Handler.Customer" >
It worked very well. Now my second challenge is....
I am using this article to implement customized paging.
Now in this article, they are using an ObjectDataSource to display the whole paging information. So I have to use 2 ObjectDataSources. Now my question is. Is it possible to bind 2 object data sources with one grid? If yes how?
May 23, 2017 09:28 AM|Zhi Lv - MSFT|LINK
As we all known, one GridView control can only handle one datasource at a time.
If you want to display data in GridView based from different tables then you could use Join clause to join the tables and using one datasource control to bind GridView.
from Employee e inner join Users u
If you want to using multiple OjectDataSource, you could set the GridView DataSourceID property from code behind, and change the data source:
Code like this:
GridView1.DataSourceID = "SqlDataSource2";
GridView1.DataSourceID = "SqlDataSource1";
Note, if you want to use multiple datasource with one GridView, please make sure the columns are same. Also, you could set the AutoGenerateColumns property to true.