Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Find ItemIndex given DataKey in DataGrid (http://www.velocityreviews.com/forums/t482850-find-itemindex-given-datakey-in-datagrid.html)

Rod 03-09-2007 11:59 AM

Find ItemIndex given DataKey in DataGrid
 
While working with a datagrid I have a value for the datakey, from this I
want to find the ItemIndex.

How please?

many thanks in advance.




Alexey Smirnov 03-09-2007 01:12 PM

Re: Find ItemIndex given DataKey in DataGrid
 
On Mar 9, 12:59 pm, "Rod" <RodRodRod...@Hotmail.com> wrote:
> While working with a datagrid I have a value for the datakey, from this I
> want to find the ItemIndex.
>
> How please?
>
> many thanks in advance.


If I got you right, you can enumerate all items...

VB:

For Each dgItem In MyDataGrid.Items

'Retrieve key value of each record based on DataGrids DataKeyField
property
If MyDataGrid.DataKeys(dgItem.ItemIndex) = datakey then

.....



Rod 03-09-2007 02:25 PM

Re: Find ItemIndex given DataKey in DataGrid
 

"Alexey Smirnov" <alexey.smirnov@gmail.com> wrote in message
news:1173445947.234839.78760@64g2000cwx.googlegrou ps.com...
> On Mar 9, 12:59 pm, "Rod" <RodRodRod...@Hotmail.com> wrote:
>> While working with a datagrid I have a value for the datakey, from this I
>> want to find the ItemIndex.
>>
>> How please?
>>
>> many thanks in advance.

>
> If I got you right, you can enumerate all items...
>
> VB:
>
> For Each dgItem In MyDataGrid.Items
>
> 'Retrieve key value of each record based on DataGrids DataKeyField
> property
> If MyDataGrid.DataKeys(dgItem.ItemIndex) = datakey then
>



That's good

Thanks




All times are GMT. The time now is 10:24 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.