If I have a datagrid that has RecNum for the primary key column, how can I return the RecNum value for the currently selected row in the datagrid
If I have a datagrid that has RecNum for the primary key column, how can I return the RecNum value for the currently selected row in the datagrid
Datagrid Current record?
Mike Phillips
No, it does not matter as long as DataView matches grid. Your code should give you what you wanted even though it's not optimal assuming column index is correct.
E.g. don't use Convert.ToInt32(), cast to it and don't use ItemArray which would copy your entire row into array which would be collected right away, use indexer instead:
recnum = (Int32)dataView[lineItemDataGrid.CurrentRowIndex][0];
Angelo_f
hwiz
Still having trouble figuing out what is happening, this code
recnum = (
Int32)dataView[lineItemDataGrid.CurrentRowIndex][0];Is giving me the row number that is sellected in the grid.
Should show RecNum 16 which is located in the fourth row first column instead it returns 4 the row number
If I select record 10 which is on another invoice(master) it is the 3rd row down(lineitemgrid) and instead of showing 10 it shows 3
RecNum in the dataBase is an auto inc field is that an issue
RecNum AutoInc
InvNum Int32
InvoiceDate DateTime
HorseName String etc..
I can submit all my code for the suming of the invoice if you would like to see it. I just need to find which lineItem was selected and changed so I can re-total the invoice.
Thanks Very Very Much
LS6FD
Please see this:
http://groups.google.com/group/microsoft.public.dotnet.framework.compactframework/browse_frm/thread/dfcc71716efc6d14/4163dbb722e3c87a &hl=en#4163dbb722e3c87a
Attila Fogel
Well Ilya:
I appreciate your answer as always, but.... theres always a but with me. :) I only got this far and I am not even sure this is the right approach. Probably I am not even close with my code.
DataView
dataView = fB7MobileDBDataSet.Tables["LineItem"].DefaultView; DataRow dataRow = dataView[lineItemDataGrid.CurrentRowIndex].Row;recnum = Convert.ToInt32(dataRow.ItemArray[0]); All I need is the first column's value RecNum
this is only giving me the first record in the table not the current position of the datagrid, this is a detail grid of a master-detail form. Does that matter