Difficulty in databinding.

Hi,

I have been working on a client-server application in c# for a few day and find that there is quite a lot of limitation and drawback in using databinding controls to dataset.  It is actually quite a new and difficult technique, right   I begin to think why using this technique and why thing have to be done in that way.  The following are the drawback I found:

1. The controls work slower after binding.
2. It is difficult to produce the format I want in the control than using old methods like Control.Items.Add().
3. If it is a form to be filled in by users, it is difficult to validate at the end when the user press OK button.  It is much more simplier to use old method of validation( do things in OKButton_Click() or Control_Leave() method).
4. It is difficult to handle programmatically change of dataset and updating of data in controls.

Many books tell only the simple method to do databinding and won't present the ways to handle data in the binding..I am getting confuse and wanna to get back to the old method.
Can anybody point to me the right direction   Thanks.


Answer this question

Difficulty in databinding.

  • Joe Lee

    1) Fact of life with binding
    2) take a look at formating via column expressions
    http://www.msdnaa.net/resources/pfv.aspx ResID=1861
    or you could either set the format property.
    3)check out
    http://www.planet-source-code.com/vb/scripts/ShowCode.asp txtCodeId=1591&lngWId=10
    Though that is based on datagrid but can be used for others. Also check out:
    http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp txtCodeId=1087&lngWId=10
    4) OK you need to get a couple of concepts down packed. 

    Dataset = holder of datatables
    Datatable = one table of data consisting of rows and columns.

    Think of a dataset more like an advanced collection.

    You create data adapters and fill datatables in a dataset using the fill method.

    Then you can easily change the data in a row of a data table in a dataset really easily
    ds.tables("mydatatable").rows(1).Item("FirstColumn") = "Hi I am changing"

    Nothing hard about that

    Then when you want to update the database you use the update of the data adapter. It will update the database of all the inserts you have done and/or updates and deletes.

    Hope this helps.

  • o?uzhan

    I thought David Sceppa's book on ADO.NET (from Microsoft Press) covered this topic well. I"ve been very happy with .NET data binding, personally. It's SOOO much better than anything provided in VB6 (where I used to work) that it's a real pleasure to use. It can be complicated getting it figured out, but it's worth it. 
  • Difficulty in databinding.