Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Databinding Issue (another one)
Message
From
18/01/2011 19:33:54
 
 
To
18/01/2011 18:25:49
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01496497
Message ID:
01496506
Views:
36
Hi Bill,

You should only have to bind it once and be done with it. If you used the same code you just showed to bind initially, you shouldn't have a problem.

Somewhere in the code for your Form (a good place is in the Load event, for example), you should have code to set up your DataBindings. I typically have a method called DataBind() where I put all this stuff (and call it from the Load eventhandler):
protected void DataBind()
{
    // put all your databinding code here, it only needs to be executed one time
    textBoxVersion.DataBindings.Add("Text", soinf.somastds.soversion, "version");
}
Once your DataSet is loaded, all your bound controls should reflect the proper contents. Since it appears yours isn't quite working correctly, I can only guess at what the problem might be. It could have something to do with mixing your binding syntax. Have a look at my blog post on this subject and see if that might be the cause of your problem:

http://geek-goddess-bonnie.blogspot.com/2009/09/keeping-datagrids-and-other-ui-controls.html

If this isn't it, then perhaps you could post some more code showing how and when you're binding.

~~Bonnie



>
>     MessageBox.Show(soinf.somastds.soversion[0].version);
>        MessageBox.Show(soinf.somastds.soversion.Rows.Count.ToString());
>        textBoxVersion.DataBindings.Clear();
>        textBoxVersion.DataBindings.Add("Text", soinf.somastds.soversion, "version");
>        MessageBox.Show(textBoxVersion.Text);
>
>The first messagebox shows"B"
>The second messagebox shows 1
>The third messagebox shows "A"
>
>At one time, the textbox was bound to a record in that DT whose version was "A"
>That row was deleted and replaced by the current row.
>How do I get that control bound properly?
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform