Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

me again :)

 

ok i´ll explain first :) the scenario

 

i have a form with 4 textboxes and a datagrid

 

if i type something in the 1st textbox it searches my database for this criteria, and then fills the results in the datagrid

 

now then i click on a row in the datagrid, i want the textboxes to get bound to the database, works all fine :)

 

but if i click on another row the databindings still exist on the textboxes and i get an error with double databindings

 

so now my question, do i always have to clear the bindings and add em again if i click on the datagrid?

 

i created the dataset and the dataadapter at runtime

  • *Experts*
Posted

If you're saying that one textbox is only used for searching and the other 3 are only to display fields from the grid, then you should only have to add the DataBindings to the three textboxes one time, preferrably when the form loads (after you've created your DataSet/DataTable).

 

If you really need to rebind the textboxes after each search, then you'll have to call Textbox.DataBindings.Clear() before adding the binding back in as you can't bind the same property more than once. You should ONLY have to do this if:

A. Your textboxes will switch between bound and unbound mode - maybe if they're in "enter params and search" mode and then they're in bound mode after the search.

B. Your DataSet variable changes to be a new DataSet. In that case, your textboxes will be bound to the "old" DataSet while the DataSet variable points to a new DataSet. I can't think of why you'd want to re-set your DataSet variable to a new instance of a DataSet, but who knows.

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
no, all 4 textboxes get bound after i click on the grid, but its good to know that i have to clear the bindings whenever i click on the grid

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...