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

Access RadListview in RadListView Item Tamplate and All In a RadGrid

1 Answer 129 Views
ListView
This is a migrated thread and some comments may be shown as answers.
zafer
Top achievements
Rank 1
zafer asked on 12 Sep 2014, 07:32 AM

Hi 

We design a radlistview in a radlistview item tamplate and thats all in a rad grid (radgrid > radlistview1 > radlistview2)
so when we update grid , we have to access radlistview2's contents but we couldn't find radlistview2 in radgridupdate_command 



our asp code 

   <telerik:RadGrid runat="server" AllowMultiRowSelection="true" AutoGenerateColumns="false" AllowFilteringByColumn="true"
                        AllowPaging="true" PageSize="10" AllowSorting="true"  ID="kategorilerGrid" AllowAutomaticInserts="true" EnableLinqExpressions="false"
                        OnItemDataBound="kategorilerGrid_ItemDataBound"
                        OnUpdateCommand="kategorilerGrid_UpdateCommand" OnDeleteCommand="kategorilerGrid_DeleteCommand"
                        OnNeedDataSource="kategorilerGrid_NeedDataSource" CssClass="RadGrid_gg RadGridRTL_gg">
                        <ClientSettings EnablePostBackOnRowClick="false">
                            <Selecting AllowRowSelect="True" EnableDragToSelectRows="true" />
                        </ClientSettings>
                        <MasterTableView CommandItemDisplay="Top" DataKeyNames="ID">
                            <EditFormSettings InsertCaption="Add new item" CaptionFormatString="Edit Item: {0}"
                                CaptionDataField="ID" PopUpSettings-Modal="true">
                            </EditFormSettings>
                            <Columns>
                                <telerik:GridEditCommandColumn ButtonType="ImageButton" />
                                <telerik:GridBoundColumn FilterControlWidth="90%" DataField="ID" UniqueName="ID" AllowFiltering="false"
                                    HeaderText="ID" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                                    Visible="false" ShowFilterIcon="false">
                                </telerik:GridBoundColumn>
                                
                                <telerik:GridButtonColumn ConfirmText="Kayıt Silinsin Mi?" ConfirmDialogType="RadWindow"
                                    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" />
                            </Columns>
                            <EditFormSettings EditFormType="Template">
                                <EditColumn ButtonType="ImageButton" />
                                <FormTemplate>
                                    <div style="height: 300px; width: 100%;">
                                        <div class="KategoriLeftEditColumn" style="margin-top: 1%;">
                                            <div class="KategoriEditRow">
                                            <div class="KategoriEditLeftRow">
                                                <asp:Label runat="server" ID="KategoriKodLabel">Kategori Kodu :</asp:Label>
                                            </div>
                                            <div class="KategoriEditRightRow">
                                                <telerik:RadTextBox runat="server" ID="KategoriKodTexBox" Width="100%" Text=' <%# Eval("KOD") %>'>
                                                </telerik:RadTextBox>
                                            </div></div>
                                           
                                            <div style="width: 100%; height:35%">
                                                <telerik:RadListView ID="radKategoriDilListView" Width="100%" DataKeyNames="ID" runat="server"
                                                    GroupItemCount="2" VirtualItemCount="2">
                                                    <ItemTemplate>
                                                        <div class="KategoriEditRow">
                                            <div class="KategoriEditLeftRow">
                                                            <asp:Label runat="server" ID="KategoriDegerLabel"><%# Eval("ISIM") %> :</asp:Label>
                                                        </div>
                                                         <div class="KategoriEditRightRow">
                                                            <telerik:RadTextBox runat="server" ToolTip=' <%# Eval("ID") %>' ID="KategoriDegerTextBox"
                                                                Width="100%" Text=' <%# Eval("DEGER") %>'>
                                                            </telerik:RadTextBox>
                                                          
                                                        </div></div>
                                                    </ItemTemplate>
                                                </telerik:RadListView>
                                            </div>
                                       
                                            <div class="KategoriEditRow">
                                               <div class="KategoriEditLeftRow">
                                                <asp:Label runat="server" ID="Label1">Kategori Sınıfı :</asp:Label>
                                            </div>
                                            <div class="KategoriEditRightRow">
                                              <telerik:RadComboBox runat="server" ID="KategoriSinifCombo" EmptyMessage="Kategori Sınıfı Seçiniz.." DataSourceID="SqlDataSource2" DataTextField="DEGER" DataValueField="ID" Width="100%"></telerik:RadComboBox>
                                            </div></div>
                                        </div>
                                        <div class="KategoriRightEditColumn" style="margin-top: 1%">
                                            <div style="width: 100%; height:100%">
                                                <telerik:RadListView ID="KategoriSlaListView" Width="100%" DataKeyNames="ID" runat="server"
                                                    GroupItemCount="2" VirtualItemCount="2">
                                                    <ItemTemplate>
                                                        <div class="KategoriEditRow">
                                            <div class="KategoriEditLeftRow">
                                                            <asp:Label runat="server" ID="KategoriSlaDegerLabel"><%# Eval("PARAMETREDEGER") %> :</asp:Label>
                                                        </div>
                                                         <div class="KategoriEditRightRow">
                                                             <telerik:RadListView ID="radKategoriSlaDilListView" Width="100%" DataKeyNames="ID" runat="server" DataSourceID="SqlDataSource3"
                                                    GroupItemCount="2" VirtualItemCount="2">
                                                    <ItemTemplate>
                                                        <div class="KategoriListEditRow">
                                            <div class="KategoriEditLeftRow">
                                                            <asp:Label runat="server" ID="KategoriDegerLabel"><%# Eval("ISIM") %> :</asp:Label>
                                                        </div>
                                                         <div class="KategoriEditRightRow">
                                                            <telerik:RadTextBox runat="server" ToolTip=' <%# Eval("ID") %>' ID="KategoriDegerTextBox"
                                                                Width="100%" Text=' <%# Eval("DEGER") %>'>
                                                            </telerik:RadTextBox>
                                                          
                                                        </div></div>
                                                    </ItemTemplate>
                                                </telerik:RadListView>
                                                              <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:TYS20DEVConnectionString %>"
            SelectCommand="(SELECT ID, ISIM, NULL AS DEGER FROM DIL)">
        </asp:SqlDataSource>
                                                        </div></div>
                                                    </ItemTemplate>
                                                </telerik:RadListView>
                                            </div>
                                           
                                        </div>
                                        <div style="width: 15%; padding-left: 85%; height: 30px; margin-bottom:0">
                                            <telerik:RadButton runat="server" ID="ParametreUpdateButton" Height="26px" Width="26px"
                                                CommandName="Update" CommandArgument=' <%# Eval("ID") %>'>
                                                <Image ImageUrl="../Images/chk.gif" IsBackgroundImage="true" />
                                            </telerik:RadButton>
                                            <telerik:RadButton runat="server" ID="RadButton1" CommandName="Cancel" Height="26px"
                                                Width="26px">
                                                <Image ImageUrl="../Images/cncl.gif" IsBackgroundImage="true" />
                                            </telerik:RadButton>
                                        </div>
                                    </div>
                                </FormTemplate>
                            </EditFormSettings>
                        </MasterTableView>
                    </telerik:RadGrid>



1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 16 Sep 2014, 01:38 PM
Hello Zafer,

For getting reference to the nested RadListView you will have to first get reference to the parent RadListView control in the edit template of the grid with FindControl() method. Then, you will need to use FindControl() from the parent RadListView items to find the nested RadListView.

Using your grid structure, following is an example for getting the nested RadListView of the first item in the parent RadListView:
(((e.Item as GridEditFormItem).FindControl("KategoriSlaListView") as RadListView).Items[0].FindControl("radKategoriSlaDilListView") as RadListView)

Please keep in mind that if you need to find controls within the nested RadListView you will need to use the items from the Items collection of the control.

Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ListView
Asked by
zafer
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or