Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Databound Textbox not Displaying Updated Info

Status
Not open for further replies.

andrea96

Programmer
Jan 26, 2001
201
US
I am having a problem with a databound textbox. Based on a button click, I am setting the value in the datarowview (bindingmanagerbase.current) to a date 6 months in the future. After bindingmanagerbase.endcurrentedit, the dataset is being updated correctly, but the date is not displayed in the textbox. All other databound controls on the form are working correctly.

However, when I clear the databindings on the textbox and then add the databinding back (without changing any other code), the textbox displays the correct date.

Has anyone run into this problem before? I guess I can always clear and re-add the binding, but that seems kind of messy.

Thanks.
 
Have you tried rebinding the textbox after the dataset is updated??

Chris
 
Once you have updated the dataset, simply:
Code:
tbName.DataBind()
Assuing that the dataset is already set up as the DataSource which it must have been as the textbox was originally working.

Hope this works

Chris
 
This is a Windows form, and from what I can tell, DataBind is only a member of Web controls. Sorry, I should have stated that in my original post. Or, am I missing something?

Here is my code.
Code:
drvKit = CType(bmbKit.Current, DataRowView)
drvKit("price_a") = lblKitPrice.Text
drvKit("quote_expires") = Today.AddMonths(6)
bmbKit.EndCurrentEdit()

The textbox bound to "price_a" is working correctly, but the textbox bound to "quote_expires" is the one with the problem.
 
Apologies, I wandered away from the ASP.NET forum this morning and forgot when I was looking through here this afternoon.

Not sure I can help. Sorry for misleading you.

Chris
 
The problem was caused because I was not consistent between binding my textboxes and the bindingmanagerbase.

Old code:
Code:
txtBox.DataBindings.Add("Text", ds.Tables("table"), "column")
bmb = Me.BindingContext(ds, "table")

New code:
Code:
txtBox.DataBindings.Add("Text", ds.Tables("table"), "column")
bmb = Me.BindingContext(ds.Tables("table"), "")

I don't know why some textboxes on the form worked and this one didn't, but the problem is now solved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top