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

Unable to get DataKeyValues in DetailsTable

1 Answer 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mario
Top achievements
Rank 1
Mario asked on 15 Oct 2011, 05:12 PM
Hello,
I have a radgrid that contains a detailstable. When I have to delete a parent record, no problem to get datakeyvalues. When I try to delete a child record, I am able to get DataKeyNames but DataKeyValues is empty!

The definition of DetailsTable is this:
         <DetailTables>
            <telerik:GridTableView name="Partecipanti" TableLayout="Fixed" DataKeyNames="PortalID,UserID,CodRiunione" AllowFilteringByColumn="false"
                DataSourceID="objDataSourceGridPartecipantiRiunione" Width="60%" HorizontalAlign="Right"
                ShowFooter="false" ShowGroupFooter="false" AllowCustomSorting="false" AllowCustomPaging="false"
                CommandItemSettings-AddNewRecordText="Conferma / Rifiuta partecipazione" CommandItemDisplay="Top"
                CommandItemSettings-ShowRefreshButton="false"
                runat="server">
                <ParentTableRelation>
                    <telerik:GridRelationFields DetailKeyField="PortalID,CodRiunione" MasterKeyField="PortalID,ItemID" />
                </ParentTableRelation>
                <Columns>
                    <telerik:GridBoundColumn Visible="false" HeaderText="PortalID" AllowFiltering="false"
                        DataField="PortalID" UniqueName="PortalID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn Visible="false" HeaderText="UserID" AllowFiltering="false"
                        DataField="UserID" UniqueName="UserID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn Visible="false" HeaderText="CodRiunione" AllowFiltering="false"
                        DataField="CodRiunione" UniqueName="CodRiunione">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderStyle-Width="200" HeaderText="Partecipanti" AllowFiltering="false"
                        DataField="Nominativo" UniqueName="Nominativo">
                    </telerik:GridBoundColumn>
                    <telerik:GridCheckBoxColumn Visible="false" HeaderText="FlgConfermaPartecipazione"
                        AllowFiltering="false" DataField="FlgConfermaPartecipazione" UniqueName="FlgConfermaPartecipazione">
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridBoundColumn HeaderStyle-Width="120" HeaderText="Stato" AllowFiltering="false"
                        DataField="ConfermaPartecipazioneTestuale" UniqueName="ConfermaPartecipazioneTestuale">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Note" AllowFiltering="false" DataField="Note" MaxLength="150"
                        UniqueName="Note">
                    </telerik:GridBoundColumn>
                    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Edit" Text="Modifica"
                        UniqueName="EditDetailCommandColumn" HeaderStyle-Width="30">
                        <HeaderStyle Width="30px"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
                    <telerik:GridButtonColumn ConfirmText="Sei sicuro di voler eliminare il partecipante da questa riunione?"
                        ConfirmDialogType="Classic" ConfirmTitle="Conferma cancellazione" ButtonType="ImageButton"
                        CommandName="Delete" Text="Elimina" UniqueName="DeleteDetailColumn" HeaderStyle-Width="30">
                        <HeaderStyle Width="30px"></HeaderStyle>
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
                </Columns>
                <EditFormSettings EditFormType="Template">
                    <FormTemplate>
                        <table border="0" cellspacing="2" cellpadding="1" width="100%" border="1" rules="none"
                            style="border-collapse: collapse">
                            <tr class="EditFormHeader">
                                <td colspan="2">
                                    <b>Conferma / Rifiuta partecipazione</b>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <table border="0" cellspacing="1" cellpadding="1" width="100%" border="0">
                                        <tr>
                                            <td>
                                                Utente:
                                            </td>
                                            <td>
                                                <telerik:RadComboBox ID="RadComboBoxUtente" runat="server" DataSourceID="objDataSourceUtentiUfficialiNonUfficialiGDL"
                                                    Filter="Contains" DataTextField="NominativoConFlagPredefinito" Width="400" DataValueField="UserID"
                                                    SelectedValue='<%# Bind("UserID") %>'>
                                                </telerik:RadComboBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Presenza:
                                            </td>
                                            <td>
                                                <telerik:RadComboBox ID="RadComboBoxPartecipazione" Width="150" runat="server" SelectedValue = '<%# Bind("FlgConfermaPartecipazione") %>' OnDataBinding="RadComboBoxPartecipazione_OnDataBinding">
                                                    <Items>
                                                        <telerik:RadComboBoxItem Text="Parteciperò" Value="1"   />
                                                        <telerik:RadComboBoxItem Text="Non parteciperò" Value="0"  />
                                                    </Items>
                                                </telerik:RadComboBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Note:
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtNote" MaxLength="150" Width="300" runat="server" Text='<%# Bind("Note") %>'>
                                                </asp:TextBox>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" colspan="2">
                                    <br /><br />
                                    <telerik:RadButton ID="btnUpdate" runat="server" Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Inserisci", "Aggiorna") %>'
                                        CssClass="MyImageButton" CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>'>
                                    </telerik:RadButton>
                                    <telerik:RadButton ID="btnCancel" Text="Annulla" runat="server" CausesValidation="False"
                                        CommandName="Cancel">
                                    </telerik:RadButton>
                                </td>
                            </tr>
                        </table>
                        <asp:HiddenField ID="hidUserID" runat="server" Value='<%# UserID %>' />
                    </FormTemplate>
                    <EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column">
                    </EditColumn>
                </EditFormSettings>
                <NoRecordsTemplate>
                    Nessun partecipante per questa riunione
                </NoRecordsTemplate>
            </telerik:GridTableView>
        </DetailTables>

and this is the line I use to retrieve datakeyvalues:
DirectCast(DirectCast(rdgrd_Agenda, Telerik.Web.UI.RadGrid).MasterTableView.DetailTables(0),Telerik.Web.UI.GridTableView).DataKeyValues(e.Item.ItemIndex)("UserID")

The array as Count=0. Where I am wrong?
Thanks

1 Answer, 1 is accepted

Sort by
0
Mario
Top achievements
Rank 1
answered on 15 Oct 2011, 06:14 PM
Solved guys, I had to pass through  GridEditableItem!
Tags
Grid
Asked by
Mario
Top achievements
Rank 1
Answers by
Mario
Top achievements
Rank 1
Share this question
or