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

Using RadComboBox in Edit mode in Subgrid

2 Answers 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stephan
Top achievements
Rank 1
Stephan asked on 09 Mar 2009, 09:14 PM
I have a Grid (SubGrid1) within a Grid (RadGrid1).
When I edit SubGrid1 I need to load values for a RadComboBox.
I'm currently loading values for RadGrid1 without problems through the RadGrid_ItemDataBound event:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)     
{     
      if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))     
      {           
           //Loading RadComboBoxes here without problems     
           //...     
      }     
      //...       
}   

When I try to do the same for SubGrid1 I came to find out that the SubGrid1_ItemDataBound event is not being called upon selecting "Edit" on this grid.

<telerik:RadGrid ID="SubGrid1" runat="server" AllowSorting="False" GridLines="None" 
    Style="margin-left: 0px" AutoGenerateColumns="False" Width="95%" OnItemDataBound="SubGrid1_ItemDataBound" OnItemCommand="SubGrid1_ItemCommand" 
     OnItemDeleted="SubGrid1_ItemDeleted" OnItemCreated="SubGrid1_ItemCreated" 
    OnItemInserted="SubGrid1_ItemInserted" OnItemUpdated="SubGrid1_ItemUpdated">  
    <HeaderContextMenu EnableTheming="True">  
        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
    </HeaderContextMenu> 
    <MasterTableView EditMode="InPlace" CommandItemSettings-AddNewRecordText="Add New Phone Number" 
        CommandItemDisplay="Top">  
        <RowIndicatorColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </RowIndicatorColumn> 
        <ExpandCollapseColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </ExpandCollapseColumn> 
        <Columns> 
            <telerik:GridEditCommandColumn HeaderStyle-Width="20px" EditText="Edit">  
                <HeaderStyle Width="20px"></HeaderStyle> 
            </telerik:GridEditCommandColumn> 
            <telerik:GridMaskedColumn Mask="(###) ###-####" 
             UniqueName="Phone" HeaderText="Phone#" DataField="Phone">  
             <HeaderStyle Width="120px" /> 
            </telerik:GridMaskedColumn> 
            <telerik:GridTemplateColumn HeaderStyle-Width="20px" UniqueName="colPhoneType">  
                <EditItemTemplate> 
                    <telerik:RadComboBox ID="PhoneType" runat="server">  
                    </telerik:RadComboBox> 
                </EditItemTemplate> 
            </telerik:GridTemplateColumn> 
            <telerik:GridTemplateColumn HeaderStyle-Width="20px" UniqueName="DeletePhoneColumn">  
                <HeaderStyle Width="20px"></HeaderStyle> 
                <ItemTemplate> 
                    <asp:ImageButton ID="imgbtnDelete" ToolTip="Delete Contact" runat="server" CommandName="Delete" ImageUrl="~/App_ThemesCustom/Pro1/images/recycle-bin-icon.gif" 
                    OnClientClick="javascript:if(!confirm('This action will delete the selected contact. Are you sure?')){return false;}" /> 
                 </ItemTemplate> 
            </telerik:GridTemplateColumn> 
        </Columns> 
        <EditFormSettings EditFormType="Template">  
            <FormStyle /> 
            <FormTemplate> 
                <asp:Table runat="server" ID="Table1" CellSpacing="1" CellPadding="1" Width="250" 
                    border="0">  
                    <asp:TableRow> 
                        <asp:TableCell></asp:TableCell> 
                        <asp:TableCell></asp:TableCell> 
                    </asp:TableRow> 
                    <asp:TableRow> 
                        <asp:TableCell> 
                            Phone Number:  
                        </asp:TableCell> 
                        <asp:TableCell> 
                            <telerik:RadTextBox ID="PhoneEdit" Text='<%# Bind( "Phone") %>' runat="server">  
                            </telerik:RadTextBox> 
                            <cc1:MaskedEditExtender ID="MaskPhoneEdit" runat="server" TargetControlID="PhoneEdit" MaskType="Number" Mask="(999) 999-9999" ClearMaskOnLostFocus="false">  
                            </cc1:MaskedEditExtender> 
                        </asp:TableCell> 
                    </asp:TableRow> 
                    <asp:TableRow> 
                        <asp:TableCell>                                                       
                            Phone Type:  
                        </asp:TableCell> 
                        <asp:TableCell ID="tblClPhoneType" runat="server" Wrap="False">  
                            <telerik:RadComboBox Width="150px" ID="RadComboPhoneType" runat="server">  
                                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
                            </telerik:RadComboBox> 
                        </asp:TableCell> 
                    </asp:TableRow> 
                      
                </asp:Table> 
                <asp:Table runat="server" Style="width: 95%">  
                    <asp:TableRow> 
                        <asp:TableCell Style="text-align: right;" ColumnSpan="2">  
                            <asp:Button ID="Button1" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>' 
                                runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>  
                            </asp:Button>&nbsp;  
                            <asp:Button ID="Button2" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel">  
                            </asp:Button> 
                        </asp:TableCell> 
                    </asp:TableRow> 
                </asp:Table> 
            </FormTemplate> 
        </EditFormSettings> 
        <NoRecordsTemplate> 
            No Records Found  
        </NoRecordsTemplate> 
        <RowIndicatorColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </RowIndicatorColumn> 
        <ExpandCollapseColumn> 
            <HeaderStyle Width="20px"></HeaderStyle> 
        </ExpandCollapseColumn> 
    </MasterTableView> 
    <ClientSettings AllowColumnsReorder="True" AllowRowsDragDrop="True" ReorderColumnsOnClient="True">  
        <Selecting AllowRowSelect="True" /> 
    </ClientSettings> 
    <FilterMenu EnableTheming="True">  
        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
    </FilterMenu> 
</telerik:RadGrid> 

protected void RadGridPhones_ItemDataBound(object sender, GridItemEventArgs e)    
{  
     //This event is not firing.  

Can anybody see anything wrong with how I do it? I don't use DataSourceID, but there has got to be a way to get it to work this way too.

The only difference between RadGrid1 and SubGrid1 is that I do an InPlace edit on SubGrid1.

Thanks.



2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Mar 2009, 04:34 AM
Hello Stephan,

I suppose that you have placed SubGrid1 in the NestedViewTemplate of RadGrid1. From your aspx code, you have set the Item DataBound event handler as OnItemDataBound="SubGrid1_ItemDataBound" but the event handler is declared as:
protected void RadGridPhones_ItemDataBound(object sender, GridItemEventArgs e)     
{   
      
}  

As per your aspx declaration, the event handler for SubGrid1 should be actually declared as:
protected void SubGrid1_ItemDataBound(object sender, GridItemEventArgs e)     
{   
      
}

Please feel free to correct me, if i'm missing out on something.
-Princy.
0
Stephan
Top achievements
Rank 1
answered on 10 Mar 2009, 12:58 PM
Hi Princy,

I pasted the wrong code snippet. It should have read:

protected void SubGrid1_ItemDataBound(object sender, GridItemEventArgs e)       
{     
     //This event is not firing.     
}    
 

Thanks for catching that and sorry for the confusion.

My control is fairly big and I meant to only paste the code relevant to this issue.
Tags
Grid
Asked by
Stephan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Stephan
Top achievements
Rank 1
Share this question
or