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

Dropdownlist not found in nestedviewtemplate of RadGrid

1 Answer 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
graham
Top achievements
Rank 1
graham asked on 16 Aug 2010, 06:18 PM
Dear All,


In my grid I have a NestedViewTemplate, which has a <asp:Panel />. I create my own expand/collapse template in this panel. Using the structure below. I am able to get access to the .text of my textbox in the template (in _Itemcommand), but the dropdownlist is always empty, and selectedvalue is nothing.

I use rgDefects_ItemCommand to fill all my textboxes and dropdowns and datepickers etc.. with the values required for the row. This all works fine. Then I have a button with a CommandName of "SaveDefect" which then also uses rgDefects_ItemCommand to read out the values. It's very strange that some controls work as expected but others don't (dropdownlists).

Any ideas?

Thanks in advance!!


My structure is basically:

 <telerik:RadGrid ID="rgDefects" runat="server" Skin="Vista" AutoGenerateColumns="false" Width="99%"  >
                 <MasterTableView DataKeyNames="DID" AllowMultiColumnSorting="True"  HierarchyLoadMode="ServerOnDemand" GroupLoadMode="Server">
                    <NestedViewTemplate>
                    <asp:Panel runat="server" ID="InnerContainer" Visible="true">
                            
                            <asp:TextBox ID="txtDescription"  runat="server" class="text-input large-input" TabIndex="1" />
                           <asp:DropDownList ID="ddlTrades" runat="server"  class="large-input" TabIndex="2" />
                   </asp:Panel>
                   </NestedViewTemplate>

                  <Columns>
                       <!-- My normal grid here. -->
                 </Columns>

                    </MasterTableView>
                </telerik:RadGrid>


My VB:

Private Sub rgDefects_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgDefects.ItemCommand

If e.CommandName = RadGrid.ExpandCollapseCommandName Then
            Dim item As GridDataItem = TryCast(e.Item, GridDataItem)

            If Not item.Expanded Then
                Dim nestedItem As GridNestedViewItem = DirectCast(item.ChildItem, GridNestedViewItem)
                Dim dataKeyValue As String = Convert.ToString(DirectCast((nestedItem.ParentItem), GridDataItem).GetDataKeyValue("DID"))

                Dim txtDescription As TextBox
                txtDescription = DirectCast(nestedItem.FindControl("txtDescription"), TextBox)
                txtDescription.text = "Test txtDescription!"

                Dim ddlTrades As DropDownList
                ddlTrades = DirectCast(nestedItem.FindControl("ddlTrades"), DropDownList)
                ddlTrades.Items.Add(New Listitem("Test1","1"))
                ddlTrades.Items.Add(New Listitem("Test2","2"))


          ElseIf e.CommandName = "SaveDefect" Then
            Dim item As GridNestedViewItem = TryCast(e.Item, GridNestedViewItem)
            Dim dataKeyValue As String = Convert.ToString(DirectCast(item.ParentItem, GridDataItem).GetDataKeyValue("DID"))

            
            Dim txtDescription As TextBox
            txtDescription = DirectCast(item.FindControl("txtDescription"), TextBox)

            Dim ddlTrades As DropDownList
            ddlTrades = DirectCast(item.FindControl("ddlTrades"), DropDownList)
            Dim t As Integer = ddlTrades.SelectedValue

End If


1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 19 Aug 2010, 01:47 PM
Hello Graham,

Please try finding the InnerContainer panel and then the controls nested in it:
Dim nestedItem As GridNestedViewItem = DirectCast(item.ChildItem, GridNestedViewItem)
Dim panel As Panel = DirectCast(nestedItem.FindControl("InnerContainer"), Panel)
Dim txtDescription As TextBox
txtDescription = DirectCast(panel.FindControl("txtDescription"), TextBox)
Dim ddlTrades As DropDownList
ddlTrades = DirectCast(panel.FindControl("ddlTrades"), DropDownList)

I hope this helps.

Greetings,
Mira
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
graham
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or