combo box problem

renjivraman

Member
Joined
Sep 9, 2006
Messages
23
Location
India
Programming Experience
1-3
hi all ,currently iam workin with the concept of dynamic binding of comboboxes, here is my problemi have a no of comboboxes which has been filled dynamically during there GOTFOCUS event.now i have created a data table which will hold the present selcted data from each of these comboboxes and try to display this table (offcourse i added the table to a dataset) using a datagrid.unfortunately iam getting only a blank row with in the datagrid.i would love to know why im getting a blank row rather than the selected values with in the comboboxes .hope u guys will help me sort this out ..regardsrenjiv
 
First of all you shouldn't be using the GotFocus event at all. If you want to do something when a control receives focus you use the Enter event, Secondly, I can't think of any valid reason to populate a control when it receives focus but not before. Thirdly, you haven't explained what you're doing in enough detail for us to be able to diagnose the issue.
 
hi,jmcilhinneythis is basically a purchase entry form where i just wanted to populate a datagrid with the selected contents(selected text) of each and every comboboxes present on the same form...during a button click event..(somethin like NEXT ITEM )thats just 4 the purpose of showing the user wat he has been selected...and after that he can make necessary changes ...or can update the information to the database..(using another btn click event).regardsrenjiv
 
So surely the ComboBoxes should be all bound from the word go, not when they receive focus. Even if the data they contain depends on another field they should be updated when that field changes, not when they receive focus. You could do all this with data binding, although it's much more tedious in .NET 1.x than it is in 2.0. At the very least you should have the grid bound to a DataTable. When the user has made their selections from the ComboBoxes and presses the button to commit you simply add a new row to that DataTable and its contents will appear in the grid.
 
hi,jmcilhinney iam workin in the same way already as u have said above my code is like this...
myDataRow("DEALERNAME")= Me.dealercombo.SelectedText
where "myDataRow" is a row in a datatable called "myDataTable" and "DEALERNAME" is a column name i have given to one of the columns in the datatable.after this i have added this datatable to a dataset and shown it using the datagridbut when i do that i receive blank columns rather than getting the selected text value in the combo box, i have tryed the same with a textbox content as follows...
myDataRow("ORDNO") = Me.txtorderno.Text
i was able to display this with in the datagrid...can u pls tell me why isnt workin with combobox
 
Last edited:
Actually i think you should also read about MVC - Model View and Controller. It may help you understand better what is going on - your psots make references that you are trying to store data in a DataGrid or DataGridView.. Sorry, but its a viewing control. It itself holds no data...
Modify the data and the grid will update..
 
ok guys,let me check all those stuff....by the way iam not using the datagrid to store the data ...im using it to display the content of a dataset (i have specifyed it in all of my posts.. )
one more thing is that i have already tried with the "selected item property"and with the "selected value property" of the comboboxand iam getting the output as "System.Data.DataRowView" (in datagrid) rather than getting that string value in the combobox.....my "adealer datarow" type is "string" and i know that the value of combobox.selecteditem will also return a string value..then why iam getting this "System.Data.DataRowView" ?if u think this is nt a professional way pls help me with some sample code ...if time permits...anyway thanks a lot 4 ur consideration
 
Last edited:
Back
Top