Click here to Skip to main content
15,908,172 members
Home / Discussions / Database
   

Database

 
Questionupdate Query with Order by Clause- SQL Server2008 Pin
Paramu197311-Jan-10 22:51
Paramu197311-Jan-10 22:51 
AnswerRe: update Query with Order by Clause- SQL Server2008 Pin
Mycroft Holmes11-Jan-10 23:21
professionalMycroft Holmes11-Jan-10 23:21 
GeneralRe: update Query with Order by Clause- SQL Server2008 Pin
i.j.russell12-Jan-10 3:54
i.j.russell12-Jan-10 3:54 
AnswerRe: update Query with Order by Clause- SQL Server2008 Pin
i.j.russell12-Jan-10 3:57
i.j.russell12-Jan-10 3:57 
AnswerRe: update Query with Order by Clause- SQL Server2008 [modified] Pin
loyal ginger12-Jan-10 4:06
loyal ginger12-Jan-10 4:06 
AnswerRe: update Query with Order by Clause- SQL Server2008 Pin
Corporal Agarn12-Jan-10 5:10
professionalCorporal Agarn12-Jan-10 5:10 
GeneralRe: update Query with Order by Clause- SQL Server2008 Pin
i.j.russell12-Jan-10 5:15
i.j.russell12-Jan-10 5:15 
QuestionGetting underlying table-column value from a selected DataGridRow [Solved] Pin
AussieLew11-Jan-10 18:07
AussieLew11-Jan-10 18:07 
(Posted on c# forum - better suited to DB)
I have an Access db with a number of related tables.
Some tables have a boolean column, eg HTReadOnly, to determine whether it is a system row (true) or not (false).
If HTReadOnly is true the user cannot edit the table row.

In a databound DataGridView, if the user chooses to Edit a row I need to check the underlying table column value, HTReadOnly for the current row and allow editing if false.

My current solution, using static methods, although reusable for different DataGridViews, requires some manual checking of design time values to protect against run time errors. eg. DataRow,column name and column type are valid etc

If I could get the row index of the table row matching the DataGridViewRow I could use...
// int pos is the required table row index matching the selected DatGridRow 
<pre>if(!MyDataSet.MyTable1[pos].HTReadOnly ) { //Allow editing of the current row }
else { // Don't allow editing };


The benefit of this method (in my mind) is the IDE and intellisense will provide the table names and check the type etc. So I know they are correct.

I tried to get pos from....
int pos = MyTable1bindingSource.Position;

however this seems to return the position of the row in the DataGridView not the table, as it doesn't match the table row when DGV sorted.

I can't seem to find a method or property for either, DataGridView, bindingSource, or TableAdapter that will return the record row index matching the currently selected DataGridViewRow.

Any Ideas?
Should I just be content getting the value of the DataGridView current row cell for my boolean value?
I read somewhere that it is better to get the actual data rather than the data loaded into the DGV, not sure why?


My current method utilizes various statics methods with
DataGridViewRow dgvr = dgv.CurrentRow;
DataRowView drv = (DataRowView)dgvr.DataBoundItem;
to be able to get the column value
eg retVal = (bool)drv.Row[colName] after various tests.


Any help would be appreciated.
Thanks...

modified on Wednesday, January 13, 2010 1:54 AM

AnswerRe: Getting underlying table-column value from a selected DataGridRow Pin
Mycroft Holmes11-Jan-10 18:40
professionalMycroft Holmes11-Jan-10 18:40 
GeneralRe: Getting underlying table-column value from a selected DataGridRow Pin
AussieLew11-Jan-10 21:27
AussieLew11-Jan-10 21:27 
GeneralRe: Getting underlying table-column value from a selected DataGridRow Pin
Mycroft Holmes11-Jan-10 22:12
professionalMycroft Holmes11-Jan-10 22:12 
GeneralRe: Getting underlying table-column value from a selected DataGridRow Pin
AussieLew12-Jan-10 0:46
AussieLew12-Jan-10 0:46 
GeneralRe: Getting underlying table-column value from a selected DataGridRow Pin
Mycroft Holmes12-Jan-10 14:00
professionalMycroft Holmes12-Jan-10 14:00 
QuestionSelecting Rows Pin
sriharsha_1210-Jan-10 19:32
sriharsha_1210-Jan-10 19:32 
AnswerRe: Selecting Rows PinPopular
Mycroft Holmes10-Jan-10 20:59
professionalMycroft Holmes10-Jan-10 20:59 
GeneralRe: Selecting Rows Pin
sriharsha_1210-Jan-10 23:08
sriharsha_1210-Jan-10 23:08 
QuestionOracle Pin
MsmVc10-Jan-10 17:14
MsmVc10-Jan-10 17:14 
AnswerRe: Oracle Pin
Mycroft Holmes10-Jan-10 18:15
professionalMycroft Holmes10-Jan-10 18:15 
AnswerRe: Oracle Pin
Jörgen Andersson10-Jan-10 21:56
professionalJörgen Andersson10-Jan-10 21:56 
Questionget list of weeks with week number Pin
Maddie from Dartford10-Jan-10 5:08
Maddie from Dartford10-Jan-10 5:08 
AnswerRe: get list of weeks with week number Pin
Herman<T>.Instance13-Jan-10 3:53
Herman<T>.Instance13-Jan-10 3:53 
QuestionProblem with subquery returning more than 1 value [Solved] Pin
James Shao10-Jan-10 4:34
James Shao10-Jan-10 4:34 
AnswerRe: Problem with subquery returning more than 1 value Pin
dan!sh 10-Jan-10 4:50
professional dan!sh 10-Jan-10 4:50 
GeneralRe: Problem with subquery returning more than 1 value Pin
James Shao10-Jan-10 15:05
James Shao10-Jan-10 15:05 
AnswerRe: Problem with subquery returning more than 1 value Pin
Ashfield10-Jan-10 5:37
Ashfield10-Jan-10 5:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.