DataView data accessor aware of sorting used

G

Guest

Is it possible somehow to retreive {data Key Value} based on clicked
{datagrid item index} ? Now i'm trying to do this in the following way, but
with no effect.
Now, Instead of getting value according to specified sort key i get wrong data


HandleInnerDGRControlItemClick(Object sender, DataGridCommandEventArgs args)
{

int clickedIndex = args.Item.ItemIndex;

....

int documentID = (int)(((DataView)((DataGrid)sender).DataSource).
Table.Rows[selectedIndex][MAIN_DATAGRID_DATAKEY]);

//documentID DOES NOT POINT VALID DOCUMENT, but something according to other
sort key

}



However, if I loop through the DataRowView Collection, I CAN find the
document ID


IEnumerator iEnum = ((DataView)((DataGrid)sender).DataSource).GetEnumerator();
int index = 0;
while(iEnum.MoveNext())
{
//Object nextObj =iEnum.Current;
DataRowView dr = (DataRowView)iEnum.Current;

if(index == selectedIndex)
{
documentID = (int)dr[MAIN_DATAGRID_DATAKEY];
//WE HAVE FOUND IT !!
break;
}
index++;
}

Is it possible that I can retreive the key of the document (documentID)
WITHOUT
the loop ?

I think that I had achieved this some time ago by using some property
exposed by DataView, but I cannot find it now.
The only property exposed by the DataView that takes into account sortKey is
the enumerator that I use to LOOP through the rows (actually DataRowView-s).
I would like to get value of {some column} of {some specified row} in the
following manner:

Object value = someData.DataView.PropertyAwareOfSorting[rowID][columnID];

is it possible ?

Thank You
Michał Januszczyk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top