This is a migrated thread and some comments may be shown as answers.

DataKeyValues count is always zero problem

1 Answer 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alexei
Top achievements
Rank 1
Alexei asked on 12 Mar 2009, 03:54 PM
Hello!

Please, I need help with the following.

 <detailtables> 
                                             
                                                <telerik:GridTableView    
                                                    runat="server"  
                                                    Width="100%"   
                                                    DataKeyNames="Field1"  
                                                    PageSize="20"  
                                                    ShowFooter="True" 
                                                    > 
                                                     
                                                     

protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
{


    int i = (int)this.RadGrid1.MasterTableView.DataKeyValues[e.Item.OwnerTableView.ParentItem.ItemIndex]["MasterField"]);
    int j = (int)this.RadGrid1.MasterTableView.DetailTables[0].DataKeyValues[e.Item.ItemIndex]["Field1"];
    // The second expression will result in "index out of bound" exception - it doesn't find any DataKeyValue elements


// WHEN I DEBUG AND LOOK AT
 
     this.RadGrid1.MasterTableView.DataKeyValues;
    // ITS COUNT IS WHAT IT'S SUPPOSED TO BE : 
 
    // BUT THIS: 
    this.RadGrid1.MasterTableView.DetailTables[0].DataKeyValues;

 // IS ALWAYS ZERO. IT DOESN'T GIVE ANY ERROR WHEN IT BINDS (I.E. THE FIELD EXISTS AND IT'S NOT EMPTY FOR IT'S A PRIMARY KEY AND I CHECKED IN DEBUG) 
// BOTH AT ITEM_COMMAND (WHEN THE COMMAND IS EXECUTED ON THE DETAIL TABLE IN QUESTION) AND EVEN IMIDEATELY AFTER BINDING IT WOULD BE ZERO; 
 
 

Am I doing something wrong there?




1 Answer, 1 is accepted

Sort by
0
Alexei
Top achievements
Rank 1
answered on 12 Mar 2009, 07:35 PM
Yo!
I found a solution:

e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["SecurityGroupId"

О какъ.
Tags
Grid
Asked by
Alexei
Top achievements
Rank 1
Answers by
Alexei
Top achievements
Rank 1
Share this question
or