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
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