Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / IDE / August 2005

Tip: Looking for answers? Try searching our database.

DataSet sorting and user

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jack - 28 Aug 2005 11:26 GMT
Hi again,

The datagrid will get a dataset. We can find out what record the user
double-clicks by the this.myDataGrid.CurrentCell.RowNumber property. But if
the user 'sorts' the datagrid, then this RowNumber property is no longer
valid - is that right? If so, how can this be tracked?

Thanks in advance...
Jack.
Scott M. - 28 Aug 2005 15:54 GMT
That's correct.  The row index in the grid will not necessarily be the same
row index as in your DataSet.  What you should do to find the DataSet index
that corresponds to the DataGrid index is:

Make sure that your DataSet stores primary key data for each row.
Make sure that this PK data is also used in your DataGrid (you don't have to
display it in the grid, but it should be stored in some hidden control at
the very least).
In your code, you can then "Find" the right row of the DataSet, based on the
PK of the row in the DataGrid like this:

(assume PartNumber is the PK field name and lblPartNum is a label in the
DataGrid that is bound to PartNumber)

Dim theRow As DataRow = ds.Tables(0).Select("PartNumber='" &
CType(e.Item.FindControl("lblPartNum"), Label).Text & "'")(0)

FindControl takes in only control names, not indexes and returns an array of
possible matching rows, so you have to specify which array element you want
at the end of the line:  (0)

-Scott

> Hi again,
>
[quoted text clipped - 5 lines]
> Thanks in advance...
> Jack.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.