?
Solved

Populate gridview with Dataset

Posted on 2007-10-17
5
Medium Priority
?
1,605 Views
Last Modified: 2008-01-09
OK Thanks

So How can I amend the following so its a Dataset that allows paging sorting on a gridview

        Database db = DatabaseFactory.CreateDatabase();
        // Get back a DataReader
        IDataReader reader = db.ExecuteReader(CommandType.StoredProcedure, "sprocname");
        gridview.DataSource = reader;
        gridview.DataBind();  
0
Comment
Question by:mugsey
  • 2
  • 2
5 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 2000 total points
ID: 20092616
A small example: C# DataGrid with DataSet
http://www.csharphelp.com/archives/archive236.html
0
 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 20093671
using(SqlConnection connection1 = new SqlConnection())
{
         connection1.ConnectionString = "...";
         SqlCommand command1 = new SqlCommand("SELECT * FROm YoutTable",connection1);
         SqlDataAdapter adapter1 = new SqlDataAdapter(command1);
         DataSet dataset1 = new DataSet();
         adapter1.Fill(dataset1);
         YourGridView.DataSource = adapter1.Tables[0].DefaultView;
         YourGridView.DataBind();
}

Now simply allow paging and sorting on your gridview

Andrew
0
 

Author Comment

by:mugsey
ID: 20093815
Have you an example using enterpise libary 3.1?
0
 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 20095952
I haven't unfortunately. Have you checked the documentation with it for examples of such nature?

Andrew :-)
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 20098962
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Integration Management Part 2
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question