aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Convert objectdatasource to dataset or datatable in | How to bind dataset with an Objectdatasource data in

Sep 29, 2010

Here I will explain how to bind dataset with objectdatasource data using


Here we need to remember that if we bind our gridview with objectdatasource that objectdatasource fill with data only whenever gridview databind is called like this 

gridview1.DataBind()=ods (ods is ObjectDataSource);

Why I have talk about this means now we are going to write function to bind dataset with objectdatasource data. We need to call this function only after gridview databind because if we call this method before the objectdatasource load with data we will get error that’s why I mention regarding this one.

Now we need to write function like this in code behind 

private DataSet GetDS(ObjectDataSource ods)
var ds = new DataSet();
var dv = (DataView)ods.Select();
if (dv != null && dv.Count > 0)
var dt = dv.ToTable();
return ds;
After execution of this function check dataset data it will bind with objectdatasource data

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Anonymous said...

Good article.
How would you populate a dataset from an AccessDataSource ?

Anonymous said...

Unknown said...

Excellent... thank's... so easy to understand...

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.