Question DatagridView ComboBox Issue

renju79

New member
Joined
Dec 13, 2009
Messages
4
Programming Experience
3-5
Hi Forum,

This is my first post and the problem which am narrating below is drooling me off.

so here's my scenario...

I have 2 datagridviews in my Windows Application.When I click on a row in the parentgrid, a child grid shows up with data regarding to which I have clicked.both grids are from the Database (SQL2005) only.

In the child grid am using a combobox and that is my headache...

this part is working fine and the problem is in the child grid.

When I try to add a new data (at the sametime into the Parent and Child) its working fine and am able to insert data into the tables...

But when I want to edit a data in the child grid, the combobox is making problem.I selected a value from the combobox and go to the next cell OMG the combobox value changed to the corresponding ID of that instead of showing the text.But I neglected this as I was getting the correct value tat has to be inserted into the DB.

Now while editing the main data am tryn to add a new child data ( assume that there are few child data already and am adding a new one).When I click save the values in the combobox are retreived as string and am not able to update the database.This happens to the rows that were already there.the reason is because of the strange behaviour of Combobox in the grid..

Am after this for 2 days and still after this..

So please help me out guys..

Also am populating the combobox from the DB only.

Please find the code below, how I did the combobox population


VB.NET:
dgvwCustomsItems.AutoGenerateColumns = False
Dim objParams As Object() = {1, 0, CDclnID, 0, 0, 0, 0, 0, 0, 0}
Dim ds, ds2 As New DataSet
ds = clsCustomItems.SearchCustomsItems(objParams) 'This is a Stored Proc. to fill the datas other than the combo
Dim objParams3 As Object() = {Nothing}

ds2 = Master.SelectAllItemsNotInGroup(objParams3) 'This is Stored Proc.. to fill the combo
         CType(dgvwCustomsItems.Columns("ColumnItemDetail"),    DataGridViewComboBoxColumn).DataSource = ds2.Tables(0)
            CType(dgvwCustomsItems.Columns("ColumnItemDetail"), DataGridViewComboBoxColumn).DisplayMember = "Item"
            CType(dgvwCustomsItems.Columns("ColumnItemDetail"), DataGridViewComboBoxColumn).ValueMember = "ID"
           
            dgvwCustomsItems.DataSource = ds.Tables(0)

dgvwCustomsItemsis my child grid.
ColumnItemDetail is the dataproperty name of my comboboxcolumn.

Thanks Renju
 
Last edited:
Solved

Ok this was solved by putting the same name for the column in the Datagridview.Earlier the dataset.tables(0) name and the gridview column were havn different names...

Thanks once again..
 
Back
Top