.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Code Snippets >> DataGrid >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Dataview from Dataset and making it as datasource for the grid

Posted By:Suderson Sarathy       Posted Date: November 22, 2010    Points: 15    Category: DataGrid    URL: http://www.dotnetspark.com  

This explains on how to create a data view from the dataset.

First hava table called "Items " in your dataset and then paste teh following code in the event which you want.

Here, "ProductId is not null" is the row filter which loads the data view only where the Productid column is not having null values.
 DataView fetch = new DataView(dstitems.Tables["Items"], "ProductId is not Null", null, DataViewRowState.CurrentRows);
if (fetch.Count > 0)
  // fetch.count will have the no.of rows retrieved from the dataview after the matching
   // applying the dataview as the datasource to the dtgmygrid.
    dtgmygrid.DataSource = fetch;



Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend