By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,627 Members | 1,870 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,627 IT Pros & Developers. It's quick & easy.

Updating values in DataGrid Cells in response to changes

P: n/a

I have a DataGridView with 2 columns called ProductID and UnitPrice.
ProductID is a combobox that displays a list of products. The user
selects a product from the combobox and a stored procedure looks up the
the products UnitPrice in the Products table and fills in the cell in the
rows UnitPrice column. The code is below. My question is, is this the
correct way of doing this or am I making a meal out of something simple?
Also in the first line of code I refer to the
'CurrentCell.OwningColumn.DataPropertyName' which I thought was better
because it is independent of the on-the-fly name given to the column, but
I couldn't find a way of finding a cell via its DataPropertyName and so I
was forced to use the cell name 'txtUnitPrice' on the update. Any
comments much appreciated. Also this code runs of the DataGridViews
'CellEndEdit' event because the cells themselves don't appear to have
events associated with them.
If MyDataGridView.CurrentCell.OwningColumn.DataProper tyName.ToString =
"ProductID" Then
Me.Bdl_GetUnitPriceTableAdapter.Fill(Me.NorthwindD ataSet.GetUnitPrice,
New _
System.Nullable(OfInteger)(Convert.ToInt32(MyDataG ridView.CurrentCell.Value)))
MyDataGridView.CurrentRow.Cells("txtUnitPrice").Va lue = _
Me.NorthwindDataSet.GetUnitPrice.Rows(0)("UnitPric e")
End If

Using Opera's revolutionary e-mail client:
Jul 14 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.