soniix Posted May 5, 2003 Posted May 5, 2003 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 Quote
*Experts* Nerseus Posted May 5, 2003 *Experts* Posted May 5, 2003 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 Quote "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
soniix Posted May 5, 2003 Author Posted May 5, 2003 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.