Hi all,
I have a nestedview on a rad grid. I am trying to follow the examples provided but I cannot make it work properly. In the onItemCommand event I am binding a formview which is in the nestedview. When I expand the first row, I can see everything properly, however all rows after that show nothing. I have made sure that I am properly binding the formview and that the datasource has valid data.
Please review the code and help.
Please help.
I have a nestedview on a rad grid. I am trying to follow the examples provided but I cannot make it work properly. In the onItemCommand event I am binding a formview which is in the nestedview. When I expand the first row, I can see everything properly, however all rows after that show nothing. I have made sure that I am properly binding the formview and that the datasource has valid data.
Please review the code and help.
protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) |
{ |
try |
{ |
RadGrid1.DataSource = myWorkorderController.getAllWorkorders("Closed"); |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
} |
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
{ |
if (e.CommandName == RadGrid.ExpandCollapseCommandName) |
{ |
if (!e.Item.Expanded) |
{ |
FormView oFormView = (FormView)RadGrid1.MasterTableView.Items[0].ChildItem.FindControl("FormView1"); |
ACareFlangeWOHistoryByWOID_inType oWOHistInfo = new ACareFlangeWOHistoryByWOID_inType(); |
oWOHistInfo.WOID = e.Item.OwnerTableView.Items[e.Item.ItemIndex]["WONUM"].Text; |
oFormView.DataSource = myWorkorderController.getAllWorkorderHistory(oWOHistInfo); |
oFormView.DataBind(); |
((GridDataItem)e.Item).ChildItem.FindControl("NestedViewPanel").Visible = |
!e.Item.Expanded; |
} |
} |
} |
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
if (!Page.IsPostBack) |
{ |
RadGrid1.MasterTableView.Items[0].Expanded = true; |
RadGrid1.MasterTableView.Items[0].ChildItem.FindControl("NestedViewPanel").Visible = true; |
} |
} |
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridNestedViewItem) |
{ |
//e.Item.FindControl("InnerContainer").Visible = ((GridNestedViewItem)e.Item).Parent.Expanded; |
} |
} |
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource" |
OnItemCommand="RadGrid1_ItemCommand" AutoGenerateColumns="False" GridLines="None" Skin="Outlook" |
AlternatingItemStyle-BackColor="#D9E6F2" ShowFooter="True" AllowFilteringByColumn="True" AllowPaging="True" |
AllowSorting="True" OnPreRender="RadGrid1_PreRender"> |
<HeaderContextMenu EnableTheming="True" Skin="Outlook"> |
<CollapseAnimation Duration="200" Type="OutQuint" /> |
</HeaderContextMenu> |
<AlternatingItemStyle BackColor="#D9E6F2" /> |
<MasterTableView Name="Workorders" PageSize="20" DataKeyNames="WONUM"> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px" /> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px" /> |
</ExpandCollapseColumn> |
<Columns> |
<telerik:GridBoundColumn DataField="CMWOID" Display="False" HeaderText="CMWOID" |
UniqueName="CMWOID" ReadOnly="true"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="WONUM" HeaderText="WO #" |
UniqueName="WONUM"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="EquipID" HeaderText="Equipment ID" |
UniqueName="EquipID" ReadOnly="true" Display="false"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn HeaderText="Equip ID" DataField="EquipID" SortExpression="EquipID"> |
<ItemTemplate> |
<asp:Label runat="server" ID="lblEquipID" Text='<% #Eval("EquipID") + " " %>'> |
</asp:Label> |
</ItemTemplate> |
<EditItemTemplate> |
<telerik:RadComboBox ID="ddlEquipID" runat="server" DataTextField="equipids" |
DataValueField="equipids" Skin="Outlook"> |
</telerik:RadComboBox> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn DataField="EquipGroup" |
HeaderText="Equip Group" UniqueName="EquipGroup"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="ProdUnit" HeaderText="Prod Unit" |
UniqueName="ProdUnit"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="ProcessUnit" HeaderText="Process Unit" |
UniqueName="ProcessUnit"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="EquipLocID" HeaderText="EquipLocID" |
UniqueName="EquipLocID" ReadOnly="true" Display="false"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn HeaderText="Location" DataField="EquipLocID" SortExpression="EquipLocID"> |
<ItemTemplate> |
<asp:Label runat="server" ID="lblEquipLocID" Text='<% #Eval("EquipLocID") + " " %>'> |
</asp:Label> |
</ItemTemplate> |
<EditItemTemplate> |
<telerik:RadComboBox ID="ddlEquipLocID" runat="server" DataTextField="Description" |
DataValueField="LocationID" Skin="Outlook"> |
</telerik:RadComboBox> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn DataField="JobType" HeaderText="Job Type" |
UniqueName="JobType" ReadOnly="true" Display="false"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn HeaderText="Job Type" DataField="JobType" SortExpression="JobType"> |
<ItemTemplate> |
<asp:Label runat="server" ID="lblJobTypeID" Text='<% #Eval("JobType") + " " %>'> |
</asp:Label> |
</ItemTemplate> |
<EditItemTemplate> |
<telerik:RadComboBox ID="ddlJobType" runat="server" DataTextField="Type" |
DataValueField="Type" Skin="Outlook"> |
</telerik:RadComboBox> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn DataField="Plant" HeaderText="Plant" |
UniqueName="Plant"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Priority" HeaderText="Priority" |
UniqueName="Priority"> |
</telerik:GridBoundColumn> |
<telerik:GridDateTimeColumn DataField="RequestDate" HeaderText="Request Date" |
UniqueName="RequestDate"> |
</telerik:GridDateTimeColumn> |
<telerik:GridBoundColumn DataField="AssignedTo" HeaderText="Assigned To" |
UniqueName="AssignedTo" ReadOnly="true" Display="false"> |
</telerik:GridBoundColumn> |
<telerik:GridTemplateColumn HeaderText="Assigned To" DataField="AssignedTo" SortExpression="AssignedTo"> |
<ItemTemplate> |
<asp:Label runat="server" ID="lblAssignedToID" Text='<% #Eval("AssignedTo") + " " %>'> |
</asp:Label> |
</ItemTemplate> |
<EditItemTemplate> |
<telerik:RadComboBox ID="ddlAssignedTo" runat="server" DataTextField="UserName" |
DataValueField="UserID" Skin="Outlook"> |
</telerik:RadComboBox> |
</EditItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn DataField="ProbDescription" HeaderText="Prob Desc" |
UniqueName="ProbDescription"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Service" HeaderText="Service" |
UniqueName="Service"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Reason" HeaderText="Reason" |
UniqueName="Reason"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="SVCCode" HeaderText="SVCCode" |
UniqueName="SVCCode"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="ReasonCode" HeaderText="ReasonCode" |
UniqueName="ReasonCode"> |
</telerik:GridBoundColumn> |
</Columns> |
<NestedViewTemplate> |
<asp:Panel ID="NestedViewPanel" runat="server" CssClass="viewWrap" Visible="false"> |
<asp:FormView ID="FormView1" runat="server"> |
<ItemTemplate> |
<div class="contactWrap"> |
<fieldset style="padding: 10px;"> |
<legend style="padding: 5px;"><b>Execution Date: <%#Eval("ExecDate") %></b> |
</legend> |
<table> |
<tbody> |
<tr> |
<td> |
<fieldset style="padding: 10px;"> |
<legend style="padding: 5px;"><b>Repair Maintenance</b> |
</legend> |
<table> |
<tbody> |
<tr> |
<td> Cause Description: </td> |
<td> |
<asp:Label ID="cityLabel" Text='<%#Bind("CauseDesc") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td> Failure Reason: </td> |
<td> |
<asp:Label ID="Label2" Text='<%#Bind("FailReason") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td>Order Problem:</td> |
<td> |
<asp:Label ID="Label3" Text='<%#Bind("OrderProblem") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td>Parts Replaced:</td> |
<td> |
<asp:Label ID="Label4" Text='<%#Bind("PartsReplaced") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td>Replace Reason:</td> |
<td> |
<asp:Label ID="Label5" Text='<%#Bind("ReplaceReason") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td>Recommendation:</td> |
<td> |
<asp:Label ID="Label6" Text='<%#Bind("Recommendation") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td>Task Sequence:</td> |
<td style="width:230px"> |
<asp:Label ID="Label7" Text='<%#Bind("TaskSeq") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td>Sec 2 Date:</td> |
<td> |
<asp:Label ID="Label8" Text='<%#Bind("Sec2Date") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td>Sec 2 Name:</td> |
<td> |
<asp:Label ID="Label9" Text='<%#Bind("Sec2Name") %>' runat="server"></asp:Label> |
</td> |
</tr> |
</tbody> |
</table> |
</td> |
<td> |
<fieldset style="padding: 10px;"> |
<legend style="padding: 5px;"><b>Preventive Maintenance</b> |
</legend> |
<table> |
<tbody> |
<tr> |
<td> Last Calibiration: </td> |
<td> |
<asp:Label ID="Label10" Text='<%#Bind("LastCalib") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td> Torque Value Used: </td> |
<td> |
<asp:Label ID="Label11" Text='<%#Bind("TorquevalUsed") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td> |
<asp:Label ID="Label30" runat="server" Text='<% #Bind("Chk1Name")%>'></asp:Label> |
</td> |
<td> |
<asp:Label ID="Label12" Text='<%#Bind("Chk1") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td> |
<asp:Label ID="Label13" runat="server" Text='<% #Bind("Chk2Name")%>'></asp:Label> |
</td> |
<td> |
<asp:Label ID="Label19" Text='<%#Bind("Chk2") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td> |
<asp:Label ID="Label14" runat="server" Text='<% #Bind("Chk3Name")%>'></asp:Label> |
</td> |
<td> |
<asp:Label ID="Label20" Text='<%#Bind("Chk3") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td> |
<asp:Label ID="Label15" runat="server" Text='<% #Bind("Chk4Name")%>'></asp:Label> |
</td> |
<td> |
<asp:Label ID="Label21" Text='<%#Bind("Chk4") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td> |
<asp:Label ID="Label16" runat="server" Text='<% #Bind("Chk5Name")%>'></asp:Label> |
</td> |
<td> |
<asp:Label ID="Label22" Text='<%#Bind("Chk5") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td> |
<asp:Label ID="Label17" runat="server" Text='<% #Bind("Chk6Name")%>'></asp:Label> |
</td> |
<td> |
<asp:Label ID="Label23" Text='<%#Bind("Chk6") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td> |
<asp:Label ID="Label18" runat="server" Text='<% #Bind("Chk7Name")%>'></asp:Label> |
</td> |
<td> |
<asp:Label ID="Label24" Text='<%#Bind("Chk7") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td> |
<asp:Label ID="Label25" runat="server" Text='<% #Bind("Chk8Name")%>'></asp:Label> |
</td> |
<td> |
<asp:Label ID="Label26" Text='<%#Bind("Chk8") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td> |
<asp:Label ID="Label27" runat="server" Text='<% #Bind("OPT1Name")%>'></asp:Label> |
</td> |
<td> |
<asp:Label ID="Label28" Text='<%#Bind("OPT1") %>' runat="server"></asp:Label> |
</td> |
</tr> |
<tr> |
<td> |
<asp:Label ID="Label29" runat="server" Text='<% #Bind("OPT2Name")%>'></asp:Label> |
</td> |
<td> |
<asp:Label ID="Label31" Text='<%#Bind("OPT2") %>' runat="server"></asp:Label> |
</td> |
</tr> |
</tbody> |
</table> |
</td> |
</tr> |
</tbody> |
</table> |
</fieldset> |
</div> |
</ItemTemplate> |
</asp:FormView> |
</asp:Panel> |
</NestedViewTemplate> |
</MasterTableView> |
<FilterMenu EnableTheming="True" Skin="Outlook"> |
<CollapseAnimation Duration="200" Type="OutQuint" /> |
</FilterMenu> |
</telerik:RadGrid> |
Please help.