Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Find ItemIndex given DataKey in DataGrid

Reply
Thread Tools

Find ItemIndex given DataKey in DataGrid

 
 
Rod
Guest
Posts: n/a
 
      03-09-2007
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.



 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      03-09-2007
On Mar 9, 12:59 pm, "Rod" <(E-Mail Removed)> 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

.....


 
Reply With Quote
 
 
 
 
Rod
Guest
Posts: n/a
 
      03-09-2007

"Alexey Smirnov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...
> On Mar 9, 12:59 pm, "Rod" <(E-Mail Removed)> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

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
How can I find the ItemIndex in a ListView? aleko ASP .Net 2 03-22-2008 01:14 AM
DataGrid change ItemIndex chandy@totalise.co.uk ASP .Net 1 01-06-2006 04:19 PM
DATASET DATAGRID ITEMINDEX DATASETINDEX Jose Fernandez ASP .Net Web Controls 4 06-01-2005 03:08 PM
ItemIndex is -1 in ItemCommand after selecting page in DataGrid Alan Eilers ASP .Net Datagrid Control 1 05-12-2004 11:17 PM
How to refer to linkbutton in datagrid using ItemIndex? susie ASP .Net Web Controls 0 09-29-2003 09:45 PM



Advertisments