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

find control in outer grid's editformtemple from inner grids update command

2 Answers 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
aykut
Top achievements
Rank 1
aykut asked on 29 Sep 2014, 10:54 AM
Hi,
I have a grid and its editformtemplate there is another grid. this inner grid maked inplace edits. I make manual update commands on inner grid to decide if I should update database or not. if I fond a problem and decide not to update database I set e.Canceled = True and want to show a warning label which is named lblneedTofindThisLabel below. Warning label is outside of inner gird, inside of formtemplate of outer grid. how can I find this control from inner grid's update command event ?

in other words:
    RadGridCompanies
        editformtemplate
            label
            InnerGrid (inplace edit)
                    Updateevent
                            -- must find label here.


<telerik:RadGrid ID="RadGridCompanies" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSourceCompanies"
             GridLines="None" AllowAutomaticDeletes="false" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
             AllowPaging="True" AllowSorting="True" CellSpacing="0" Width="900px" Skin="Web20" PageSize="20">
             <GroupingSettings CaseSensitive="false" />
 
             <ClientSettings AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true" EnableRowHoverStyle="True">
                 <Selecting AllowRowSelect="true" />
                 <Selecting AllowRowSelect="True"></Selecting>
             </ClientSettings>
 
 
             <MasterTableView DataKeyNames="ID, guidid" DataSourceID="SqlDataSourceCompanies" CommandItemDisplay="Top"
                 EditMode="PopUp">
                 <CommandItemSettings ExportToPdfText="Export to PDF"
                     ShowRefreshButton="False"></CommandItemSettings>
                 <RowIndicatorColumn>
                     <HeaderStyle Width="20px"></HeaderStyle>
                 </RowIndicatorColumn>
                 <ExpandCollapseColumn>
                     <HeaderStyle Width="20px"></HeaderStyle>
                 </ExpandCollapseColumn>
 
                 <Columns>
                     <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" HeaderText="ID" ReadOnly="True" SortExpression="ID" UniqueName="ID" Visible="false">
                         <ColumnValidationSettings>
                             <ModelErrorMessage Text=""></ModelErrorMessage>
                         </ColumnValidationSettings>
                     </telerik:GridBoundColumn>
                     <telerik:GridBoundColumn DataField="guidid" HeaderText="guidid" ReadOnly="True" SortExpression="guidid" UniqueName="guidid" Visible="false">
                         <ColumnValidationSettings>
                             <ModelErrorMessage Text=""></ModelErrorMessage>
                         </ColumnValidationSettings>
                     </telerik:GridBoundColumn>
                     
                    .... other columns..
 
                  <EditFormSettings EditFormType="Template" PopUpSettings-Width="950px" PopUpSettings-Height="650px">
                               <EditColumn UniqueName="EditCommandColumn1">
                               </EditColumn>
                               <FormTemplate>
                                  
                                  
                                  <telerik:RadGrid ID="RadGridMids" runat="server" AllowAutomaticUpdates="false" OnUpdateCommand="RadGridMids_UpdateCommand"
                                             DataSourceID="SqlDataSourceMids" GridLines="None" Skin="Web20" AutoGenerateColumns="False" CellSpacing="0" Width="800px">
                                             <ClientSettings EnableRowHoverStyle="True">
                                             </ClientSettings>
                                             <MasterTableView DataKeyNames="ID" DataSourceID="SqlDataSourceMids" EditMode="InPlace" CommandItemDisplay="Top">
                                                 <Columns>
                                                     <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" HeaderText="ID" ReadOnly="True" UniqueName="ID" Visible="false"></telerik:GridBoundColumn>
 
                                                     <telerik:GridTemplateColumn DataField="Bank" FilterControlAltText="Filter BankName column" HeaderText="Bank" SortExpression="Bank" UniqueName="Bank">
                                                         <EditItemTemplate>
                                                             <asp:TextBox ID="BankTextBox" runat="server" Text='<%# Bind("Bank") %>'></asp:TextBox>
                                                         </EditItemTemplate>
                                                         <ItemTemplate>
                                                             <asp:Label ID="BankLabel" runat="server" Text='<%# Eval("Bank") %>'></asp:Label>
                                                         </ItemTemplate>
                                                          
                                                         ... other columns...
                                                          
                                                     </telerik:GridTemplateColumn>
                                                            <telerik:GridEditCommandColumn>
                                                     </telerik:GridEditCommandColumn>
                                                 </Columns>
                                                 <EditFormSettings>
                                                     <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                                                 </EditFormSettings>
                                             </MasterTableView>
                                             <FilterMenu EnableTheming="True">
                                                 <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                                             </FilterMenu>
                                 </telerik:RadGrid>
                                          
                                <asp:Label ID="lblneedTofindThisLabel" runat="server" Text="label to find" Visible="false" ></asp:Label>
                                                             
                     </FormTemplate>
                     <PopUpSettings Modal="True" Width="1000px" />
                 </EditFormSettings>
 
             </MasterTableView>
             <FilterMenu EnableImageSprites="False">
             </FilterMenu>
         </telerik:RadGrid>

and the code is :

Protected Sub RadGridMids_UpdateCommand(sender As Object, e As GridCommandEventArgs)
 
      Dim editedItem As GridEditableItem = TryCast(e.Item, GridEditableItem)
      Dim ID_ As String = editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)("ID").ToString()
       
     ' .... some logic....
       
     ' -- WHAT X should be. ?
       
      Dim lblneedTofindThisLabel As Label = (TryCast(x.FindControl("lblneedTofindThisLabel"), Label))
       
      lblneedTofindThisLabel.visible=true
         end sub

2 Answers, 1 is accepted

Sort by
0
aykut
Top achievements
Rank 1
answered on 29 Sep 2014, 11:06 AM
nevermind.. I found it :) Interesting thing is I found solution in my own project which means I already sovled problem.

sorry...

For Each editedItemMain As GridEditFormItem In RadGridCompanies.MasterTableView.GetItems(GridItemType.EditFormItem)
               If editedItemMain.IsInEditMode Then
                   lblneedTofindThisLabel= (TryCast(editedItemMain.FindControl("lblneedTofindThisLabel"), Label))
               End If
           Next
0
Eyup
Telerik team
answered on 02 Oct 2014, 08:16 AM
Hello Aykut,

I'm glad you've managed to find a viable solution by yourself.
You can also try implementing a custom validator for similar scenarios:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidator%28v=vs.110%29.aspx

Regards,
Eyup
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
Grid
Asked by
aykut
Top achievements
Rank 1
Answers by
aykut
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or