Binding a control to a non-design time dataset

  • Thread starter Thread starter Andy Gilman
  • Start date Start date
A

Andy Gilman

Designers are great, but they have limitations : Ergo...

* I am using a strongly typed dataset
* So I make my form and textfields A, B, C, D, E, F, G, H on it.
* I create an instance of my stongly typed dataset in the designer, lets
call this DS
* I bind controls A-H to this dataset.
* All this code becomes a reusable user control X

Meanwhile in my GUI + dataaccess layers....

* I have a form which contains the above control X
* That form calls my data access which returns me a datarow R that can be
bound to usercontrol X
* This datarow is part of a NEW dataset (since the dataaccess layer knows
nothing about my usercontrol)
* I want to set this datarow R to be the datasource for X

To get this to work I need to do one of the following :
* I need to rebind all the controls to the new datarow when i set the
usercontrol's datasource
or
* Instead load the datarow directly into the dataset for the user control.
or
* Use a global dataset for all user controls. I dont like this idea because
it is not very modular.

The first is clumsy. The second is TERRIBLE. The user control shouldnt know
anything about the data layer. It should just be able to edit me my datarow
without problems.

Whats the best way to achieve what I'm trying to do. What are most people
doing?

We shouldnt be satisfied with loading data in the Form as Microsoft seems to
think we should.

-andy
 
Hi Andy,

Just a thought, but you could try not using a strongly typed dataset.

Mostly samples given in this dotnet newsgroups are not accoording to that.

However, just my thought,

Cor
 
i think you misunderstood my post. whether you use a strongly typed dataset
or not - it doesnt make any difference to how databinding works, only in how
it is set up in the designer.

-simon
 
Back
Top