PC Review


Reply
Thread Tools Rate Thread

Finding a DataRow index

 
 
William Ryan
Guest
Posts: n/a
 
      24th Aug 2003
The datagrid has a CurrentCell property that gives you
both row and column information. As long as you don't
sort the grid, you can just check the currectcell and
you'll have the row index.

If you are sorting though, let me know and we can take a
different approach.

Good Luck,

Bill
>-----Original Message-----
>In my design I have a table bound to a datagrid. I want

to select the
>datagrid row which corresponds with a row in the bound

table.
>
>Using a primary key is not an option because records get

deleted leaving
>holes and the data is not sorted by PK anyway.
>
>Does anyone know how to do this without reading all the

tableRows to find
>the position ?
>
>
>TIA
>
>--
>Regards - One Handed Man
>
>Author : Fish .NET & Keep .NET
>
>==============================
>
>
>.
>

 
Reply With Quote
 
 
 
 
One Handed Man
Guest
Posts: n/a
 
      25th Aug 2003
Sorry Bill, maybe I didnt make myself clear on this one.

Assume you programatically create a new row by adding it to the table. When
the table is refilled by the dataadapter, the new row takes a new position
because it is being sorted by the persons name in th SQL select command.
(SELECT * FROM People ORDER By FirstName ).

Having found and preserved the new ID number using executescalar with a
MAX(ID) in the select statement, I can find the row created using the
Table.Find( ID ) method as I have a PKey on this table on column zero.
However I dont know what row position this is in the table so I dont know
how to select the newly created and corresponding row in the grid.

Hope you can shed some light on a way forward . . ., to me this seems like
an oversight, Ican locate the underying row using Grid.CurrentRowIndex but
cant datagrid.Select(row) because I dont know it .... see the dialema ?



--
Regards - One Handed Man

Author : Fish .NET & Keep .NET

==============================
"William Ryan" <(E-Mail Removed)> wrote in message
news:013401c36a77$ab386c40$(E-Mail Removed)...
> The datagrid has a CurrentCell property that gives you
> both row and column information. As long as you don't
> sort the grid, you can just check the currectcell and
> you'll have the row index.
>
> If you are sorting though, let me know and we can take a
> different approach.
>
> Good Luck,
>
> Bill
> >-----Original Message-----
> >In my design I have a table bound to a datagrid. I want

> to select the
> >datagrid row which corresponds with a row in the bound

> table.
> >
> >Using a primary key is not an option because records get

> deleted leaving
> >holes and the data is not sorted by PK anyway.
> >
> >Does anyone know how to do this without reading all the

> tableRows to find
> >the position ?
> >
> >
> >TIA
> >
> >--
> >Regards - One Handed Man
> >
> >Author : Fish .NET & Keep .NET
> >
> >==============================
> >
> >
> >.
> >



 
Reply With Quote
 
Roy Osherove
Guest
Posts: n/a
 
      25th Aug 2003
Perhaps this might help - look at lesson 4 in the bottom:
http://weblogs.asp.net/rosherove/posts/9088.aspx

--
Regards,

Roy Osherove
http://www.iserializable.com
---------------------------------------------

"One Handed Man" <terry_burnsREMOVE%FOR%NO%(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> Sorry Bill, maybe I didnt make myself clear on this one.
>
> Assume you programatically create a new row by adding it to the table.

When
> the table is refilled by the dataadapter, the new row takes a new position
> because it is being sorted by the persons name in th SQL select command.
> (SELECT * FROM People ORDER By FirstName ).
>
> Having found and preserved the new ID number using executescalar with a
> MAX(ID) in the select statement, I can find the row created using the
> Table.Find( ID ) method as I have a PKey on this table on column zero.
> However I dont know what row position this is in the table so I dont know
> how to select the newly created and corresponding row in the grid.
>
> Hope you can shed some light on a way forward . . ., to me this seems like
> an oversight, Ican locate the underying row using Grid.CurrentRowIndex but
> cant datagrid.Select(row) because I dont know it .... see the dialema ?
>
>
>
> --
> Regards - One Handed Man
>
> Author : Fish .NET & Keep .NET
>
> ==============================
> "William Ryan" <(E-Mail Removed)> wrote in message
> news:013401c36a77$ab386c40$(E-Mail Removed)...
> > The datagrid has a CurrentCell property that gives you
> > both row and column information. As long as you don't
> > sort the grid, you can just check the currectcell and
> > you'll have the row index.
> >
> > If you are sorting though, let me know and we can take a
> > different approach.
> >
> > Good Luck,
> >
> > Bill
> > >-----Original Message-----
> > >In my design I have a table bound to a datagrid. I want

> > to select the
> > >datagrid row which corresponds with a row in the bound

> > table.
> > >
> > >Using a primary key is not an option because records get

> > deleted leaving
> > >holes and the data is not sorted by PK anyway.
> > >
> > >Does anyone know how to do this without reading all the

> > tableRows to find
> > >the position ?
> > >
> > >
> > >TIA
> > >
> > >--
> > >Regards - One Handed Man
> > >
> > >Author : Fish .NET & Keep .NET
> > >
> > >==============================
> > >
> > >
> > >.
> > >

>
>



 
Reply With Quote
 
One Handed Man
Guest
Posts: n/a
 
      26th Aug 2003
OK. Thanks for your post. I took a look at it but unless i am missing
something ( and I probably am ), in order to find the row you need to sort
by index. Fine, but once you sort the position changes and hence you dont
know where the real position is on the datagrid which is what I need.



--
Regards - One Handed Man

Author : Fish .NET & Keep .NET

==============================
"Roy Osherove" <(E-Mail Removed)> wrote in message
news:eSp%(E-Mail Removed)...
> Perhaps this might help - look at lesson 4 in the bottom:
> http://weblogs.asp.net/rosherove/posts/9088.aspx
>
> --
> Regards,
>
> Roy Osherove
> http://www.iserializable.com
> ---------------------------------------------
>
> "One Handed Man" <terry_burnsREMOVE%FOR%NO%(E-Mail Removed)> wrote in
> message news:(E-Mail Removed)...
> > Sorry Bill, maybe I didnt make myself clear on this one.
> >
> > Assume you programatically create a new row by adding it to the table.

> When
> > the table is refilled by the dataadapter, the new row takes a new

position
> > because it is being sorted by the persons name in th SQL select command.
> > (SELECT * FROM People ORDER By FirstName ).
> >
> > Having found and preserved the new ID number using executescalar with a
> > MAX(ID) in the select statement, I can find the row created using the
> > Table.Find( ID ) method as I have a PKey on this table on column zero.
> > However I dont know what row position this is in the table so I dont

know
> > how to select the newly created and corresponding row in the grid.
> >
> > Hope you can shed some light on a way forward . . ., to me this seems

like
> > an oversight, Ican locate the underying row using Grid.CurrentRowIndex

but
> > cant datagrid.Select(row) because I dont know it .... see the dialema ?
> >
> >
> >
> > --
> > Regards - One Handed Man
> >
> > Author : Fish .NET & Keep .NET
> >
> > ==============================
> > "William Ryan" <(E-Mail Removed)> wrote in message
> > news:013401c36a77$ab386c40$(E-Mail Removed)...
> > > The datagrid has a CurrentCell property that gives you
> > > both row and column information. As long as you don't
> > > sort the grid, you can just check the currectcell and
> > > you'll have the row index.
> > >
> > > If you are sorting though, let me know and we can take a
> > > different approach.
> > >
> > > Good Luck,
> > >
> > > Bill
> > > >-----Original Message-----
> > > >In my design I have a table bound to a datagrid. I want
> > > to select the
> > > >datagrid row which corresponds with a row in the bound
> > > table.
> > > >
> > > >Using a primary key is not an option because records get
> > > deleted leaving
> > > >holes and the data is not sorted by PK anyway.
> > > >
> > > >Does anyone know how to do this without reading all the
> > > tableRows to find
> > > >the position ?
> > > >
> > > >
> > > >TIA
> > > >
> > > >--
> > > >Regards - One Handed Man
> > > >
> > > >Author : Fish .NET & Keep .NET
> > > >
> > > >==============================
> > > >
> > > >
> > > >.
> > > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ADO.NET, need to get index of datarow BB Microsoft VB .NET 7 17th Nov 2005 03:53 AM
enum as index for DataRow marc.gibian@ACM.ORG Microsoft C# .NET 4 12th Jan 2005 10:34 PM
DataRow index Nabeel Moeen Microsoft Excel Programming 2 27th Feb 2004 02:18 PM
Finding the index of the DataRow to update? Doug Microsoft ASP .NET 0 2nd Dec 2003 10:24 PM
DataRow Index Mauricio Microsoft ADO .NET 5 10th Nov 2003 02:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:41 PM.