?
Solved

Get row in datagrid

Posted on 2006-04-22
3
Medium Priority
?
350 Views
Last Modified: 2010-04-23
Hello,

I have a datagrid that is based on a dataset. I can access the data in code with the datagrid.item( row, column) function, but I have one problem : the user can select the order of the columns himself, so the columnnumber doesn't always have the same data. He can also sort the datagrid by clicking on the header.

So I would like to get the rownumber in the dataset that corresponds to the rownumber in the datagrid, so I can access data through a row:
  dim localrow as mydataset.myrow

  localrow = mydataset.myrow(..)
  string = localrow.field

No what I don't figure out is how to assign the correct row.  Can you help me ?
0
Comment
Question by:ACAE
3 Comments
 
LVL 4

Expert Comment

by:VIkasumit
ID: 16514676
Hi,

you can use your Data's ID , since you are showing Datagrid it must have some ID associated to it, like product id which is unique for your datagrid, use that value to identify your row.

Hope I am clear

VIkasumit
0
 
LVL 14

Accepted Solution

by:
jake072 earned 500 total points
ID: 16514876
If you want the currently selected row:

    Dim cm As CurrencyManager = CType(dg.Parent.BindingContext(dg.DataSource, dg.DataMember), CurrencyManager) ' Where dg = your DataGrid

    ' Retrieve the default DataView of the DataGrid
    Dim dv As DataView = CType(cm.List, DataView)

   Dim localrow As DataRow = dv.Item(dg.CurrentRowIndex).Row

Jake
0
 

Author Comment

by:ACAE
ID: 16526660
It seems to work fine, thx for your help !
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Loops Section Overview
Suggested Courses
Course of the Month13 days, 12 hours left to enroll

755 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question