Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataSet Haschanges returning false
Message
 
À
30/10/2012 11:01:54
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:
01556153
Vues:
49
Hi Bonnie, I now understand more of the *workings* of binding, and , as you say, I should flush the DataRow values not the controls *Text* values - thanks for your help


Pete


>>Hi Bonnie, I naively thought that DataBinding would work both ways, my original post was asking why the DataTable HasChanges() wasn't returning true, it was Bill that introduced WriteValue() to the thread, thanks again.
>
>Well, it *does* work both ways, but only from a UX standpoint. If a *user* typed in those TextBoxes, then yeah, your HasChanges() would be true.
>
>I guess I don't understand what you're trying to do, unfortunately, to need that bit of code that you posted below. Are you going to change it to wipe out the DataTable row instead of the TextBoxes?
>
>~~Bonnie
>
>
>>
>>
>>
>>>>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
Répondre
Fil
Voir

Click here to load this message in the networking platform