Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataSet Haschanges returning false
Message
 
À
31/10/2012 12:26:23
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01554541
Message ID:
01556219
Vues:
53
Hi Bill, I actually don't use DataBinding at all now but recently I was asked to change an old app I wrote years ago when learning c# and the whole .net thing, these days I have classes for every table and all data related tasks are handled by them. Much cleaner and easier to maintain.

Pete

>Hey Pete,
>
>No prob. Glad you had a chance to learn some new things and implement a solution. I ran into the same issues when trying to learn Windows Forms binding. Data binding is usually problemmatic on virtually any platform.
>
>I now try to do more work with the Data Source for modifying data programmatically but there are always times when it might be necessary to modify the data at the Control level.
>
>Bill
>
>>Hi Bill, I now understand *binding* more than I did and now have a solution - thanks for your help
>>
>>Pete
>>
>>
>>>Hey Bonnie,
>>>
>>>Yes, this is why I suggested he look at ReadValue() and WriteValue() because he was doing a programmatic update of the control which requires a post of the data to the data source.
>>>
>>>Bill
>>>
>>>>>I thought the whole point of DataBinding was to automate this sort of behaviour.
>>>>
>>>>It is. I don't know why you'd have to do this if you've properly databound those controls. I thought the problem you initially wrote about was because you programmatically changed the value in a control (say, a TextBox.Text) and you needed to use the .WriteValue() for that reason, for one or two controls perhaps.
>>>>
>>>>If you're regularly clearing the values in all your controls by the below methodology (setting all TextBox.Text = ""), then your problem is actually that you shouldn't be doing it that way. Those TextBoxes are bound to a DataTable ... you should be clearing the data in the DataTable row and those empty values will then be shown in your TextBoxes.
>>>>
>>>>~~Bonnie
>>>>
>>>>
>>>>
>>>>>Hi all, just to update you on what I ended up coding ( please advise if there's a cleaner way )
>>>>>
>>>>>
>>>>>// This method clears the controls values.
>>>>>
>>>>>this.txtFirstName.Text = "";
>>>>>this.txtMiddleName.Text = "";
>>>>>// And so on for the other controls.
>>>>>
>>>>>// Loop to WriteValues to dataset
>>>>>
>>>>>for(int i = 0 ; i < this.Controls.Count ; i++)
>>>>>    if(this.Controls[i].DataBindings.Count > 0)
>>>>>        for(int j = 0 ; j < this.Controls[i].DataBindings.Count  ; j++)
>>>>>            this.Controls[i].DataBindings[j].WriteValue();
>>>>>
>>>>>
>>>>>I thought the whole point of DataBinding was to automate this sort of behaviour. Once again, thanks for your help.
Regards,
Peter J. Kane



Pete
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform