?
Solved

How to bind a GridView to a DataTableReader

Posted on 2009-02-11
4
Medium Priority
?
891 Views
Last Modified: 2013-12-17
I have a

DataTableReader dtr
GridView gv1

How do I bind the first result set of dtr to gv1 and have all the columns show so that I can traverse through all the records.

What is the best way to do this, I am just looking for something quick and dirty.

Thanks.

-Rowan
0
Comment
Question by:rowansmith
  • 2
  • 2
4 Comments
 
LVL 6

Expert Comment

by:havj123
ID: 23619413
DataTableReader dtr
GridView gv1

If your DataTableReader is not null than

gv1.datasource = dtr;
gv1.databind()

OK.
0
 
LVL 6

Accepted Solution

by:
havj123 earned 2000 total points
ID: 23619416
Correct the code

DataTableReader dtr
GridView gv1

If your DataTableReader is not null than

gv1.datasource = dtr;
gv1.databind();
0
 
LVL 11

Author Comment

by:rowansmith
ID: 23619940
There is no databind method.. this is .NET 3.5 and I just realised it is a datagridview class.
0
 
LVL 11

Author Comment

by:rowansmith
ID: 23620116
I found the following on another site and it worked so I went with it.  the original parameters have changed so the question is no longer valid.

I have no idea what the following two lines do or even if they are both required but it works and as I am only doing this for a debug function I don;t need to undestand the datagridview class (yet).

Thanks.

public TableGridView(DataSet ds,string tableName)
        {
       

            dataGridView1.DataSource = ds.Tables[tableName].DefaultView;
            dataGridView1.DataSource = ds.Tables[tableName];
        }
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month15 days, 7 hours left to enroll

840 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