Best Method For Binding to a Datagrid?

  • Thread starter Thread starter John Smith
  • Start date Start date
J

John Smith

Hey folks,

I'm writing a Windows application which has many forms which have Datagrids
on them to display data. These datagrids will not be editable in anyway.
They are there to just view the results of a query (and perhaps double click
on a row to open a new form). Additionally, the queries will often involve
the use of 5 or more tables.

Because efficiency (both speed and memory) is the primary concern what is
the best method to bind to the datagrid?

Coming from a C# asp.net background, I was surprised to see that it appears
you can't bind a SqlDataReader to the datagrid. All examples I've seen
involve using a DataSet and a SqlDataAdapter. Is that really the only and
best way? What other effecient solutions are there? (forward-only
solutions are fine)

Thanks!
 
That's correct, you can't bind ot a reader. If you're going to use the
DataBindings, there's not a whole lot you can do to affect the efficiency
AFAIK. Loading Lookup tables for instance in a background thread when the
app starts, holding them in a static property and not reloading them each
time you need to populate a control will increase the speed b/c you won't
have to keep making trips to the db each time you open an instance of the
same form - but this doesn't affect the bindings per se.

--
W.G. Ryan MVP Windows - Embedded

Have an opinion on the effectiveness of Microsoft Embedded newsgroups?
Let Microsoft know!
https://www.windowsembeddedeval.com/community/newsgroups
 
That's correct, you can't bind ot a reader. If you're going to use the
DataBindings, there's not a whole lot you can do to affect the efficiency

Would I be better off not using databindings and populating the datagrid by
looping through a datareader and adding to it a row at a time? Or is there
another non-databinding alternative solution I should consider?

AFAIK. Loading Lookup tables for instance in a background thread when the
app starts,

I need the data to be real time. Thanks though.
 
Back
Top