Re: DataGrid.Binding()

From: Jeffrey Palermo [MCP] (http://dotnetjunkies.com/weblog/jpalermo)
Date: 07/26/04


Date: Sun, 25 Jul 2004 21:52:30 -0500

Dmitri,
    It really depends on what you are doing. I, for instance, steer away
from the DataSet object. I usually don't have a need for its features. A
dataset is very useful if you need to have several tables linked together in
a parent/child relationship or in some other fashion. When I need to bind
data, I find that I have a single set of data. If I were to use the dataset
for this, I would be creating an object with more overhead than I need. I
usually have a custom object for every entity that I work with, so I would
just use a datareader from the database to create a collection of these
objects. If your data is very simple, you could just create an array of
strings to which to bind. Bindable controls can bind to any object that has
primitive public properties such as string and int.

Also, in question number 2, you are confusing a web control with an ADO.NET
object. You cannot bind a DataTable with a custom object. A DataTable is a
container object commonly used within a DataSet. A Datagrid can be bound TO
a DataTable or other custom object or simply an array. Check out the SDK
documentation on databinding.

Best regards,
Jeffrey Palermo

"Just D" <no@spam.please> wrote in message
news:yYZMc.11217$BX.10688@lakeread08...
> Hi,
>
> If anybody needs to show some data retrieved from the database table, what
> method is more preferrable?
>
> 1. DataSet ds = ...;
> DataGrid.Data.Source.ds;
> DataGrid.Bind();
>
> 2. Write a custom object, fill it with the DataSet data and ерут try to
bind
> the DataGrid or DataTable and this custom object?
>
> I usually don't allow users to change anything irectly in the DataGrid,
but
> I allow to select a row and then show a set of TextBoxes, DropDown lists
> etc. to correct/enter data. Is it a good approach or it's better to allow
> userworking with the DataGrid directly and then Update this DataSet or
> whatever?
>
> Thanks,
> Dmitri
>



Relevant Pages

  • Custom Object in a Datagrid
    ... I have ready many posts on binding a collection of one custom object ... What i want to do is not that, but to bind a collection ... Customer and Address. ... THE PROBLEM is the setting of those fields in the datagrid. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Best Method For Binding to a Datagrid?
    ... you can't bind ot a reader. ... Would I be better off not using databindings and populating the datagrid by ... >> you can't bind a SqlDataReader to the datagrid. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Error: No default member found for type MyClass
    ... Return CType, clsAgentPostalCode) ... Dim oAgentPostalCodeCollection As New clsAgentPostalCodeCollection ... > You try to make from your dataset a collection to bind that to a datagrid. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: ASP.NET Remoting problem
    ... > I have added a web reference to this service. ... > But now I cannot bind an array of this object to a DataGrid because ... > properties to be able to bind with data grid. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASP.NET Remoting problem
    ... > I have added a web reference to this service. ... > But now I cannot bind an array of this object to a DataGrid because ... > properties to be able to bind with data grid. ...
    (microsoft.public.dotnet.framework.aspnet)