I have two grids. The first is a graphic selecting grid:
<telerik:radwindow runat="server" id="rwGraphics" visibleonpageload="false">
<ContentTemplate>
<asp:UpdatePanel ID="Updatepanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Literal ID="GraphicType" runat="server" Visible="false" />
<asp:Literal ID="CurrentID" runat="server" Visible="false" />
<asp:Literal ID="litJS" Runat="server"/>
<div align='center'>
<table width='300' cellpadding='0' >
<tr>
<td width='100%' colspan="3" align='left'>
<telerik:RadGrid ID="rg_graphics" runat="server" AllowSorting="true" AutoGenerateColumns="false" Width="100%" GridLines="Both"
BorderStyle="None" ShowFooter="false" ShowHeader="true" AlternatingItemStyle-BackColor="WhiteSmoke" AllowAutomaticInserts="false" restrictionzoneId="ContentTemplateZone" >
<HeaderStyle BackColor="#000084" Font-Bold="true" ForeColor="White" HorizontalAlign='left' />
<MasterTableView OverrideDataSourceControlSorting="true" DataKeyNames="GraphicId" ShowHeader="false" >
<Columns>
<telerik:GridButtonColumn ItemStyle-Wrap="false" CommandName="AddGraphic" ButtonType="LinkButton" Text="Add File" />
</Columns>
<ItemTemplate >
<asp:hyperlink runat='server' id='hl_graphic' Target='_blank' CssClass='login' navigateurl='<%#getGraphicPath(DataBinder.Eval(Container.DataItem, "GraphicID"))%>'><%#DataBinder.Eval(Container.DataItem, "Description")%></asp:hyperlink>
</ItemTemplate>
</MasterTableView>
</telerik:RadGrid><br />
<asp:Label ID='l_noresults' Runat='server'><font color='firebrick'><b>No Graphics Found</b></font></asp:Label>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</telerik:radwindow>
The next grid is what calls the first grid.
<tr>
<td class="RightAlignHeader" width="1%" nowrap="nowrap">Answers</td>
<td>
<telerik:RadGrid ID="rg_Answers" runat="server" AllowSorting="true" AutoGenerateColumns="false" Width="100%" GridLines="Both"
BorderStyle="None" ShowFooter="false" ShowHeader="true" AlternatingItemStyle-BackColor="WhiteSmoke" AllowAutomaticInserts="false" >
<HeaderStyle BackColor="#000084" Font-Bold="true" ForeColor="White" HorizontalAlign='left' />
<MasterTableView OverrideDataSourceControlSorting="true" CommandItemDisplay="Top" AllowSorting="true" DataKeyNames="AnswerId" ShowHeadersWhenNoRecords="true" CommandItemSettings-AddNewRecordText="Add New Answer">
<Columns>
<telerik:GridButtonColumn UniqueName="btnDelete" Text="Delete" ConfirmText="Confirm delete?" ButtonType="LinkButton" CommandName="Delete" ItemStyle-Width="1%" />
<telerik:GridButtonColumn UniqueName="btnEdit" Text="Edit" ButtonType="LinkButton" CommandName="Edit" ItemStyle-Width="1%" />
<telerik:GridBoundColumn UniqueName="Text" DataField="Text" HeaderText="Answers" ItemStyle-Wrap="false" SortExpression="Text"/>
<telerik:GridCheckBoxColumn UniqueName="IsCorrect" DataField="IsCorrect" HeaderText="Correct" SortExpression="IsCorrect" DefaultInsertValue="False" />
<telerik:GridImageColumn UniqueName="AnswerGraphic" HeaderText="Graphic"/>
<telerik:GridTemplateColumn Display="false" UniqueName="AnswerGraphicColumn" >
<EditItemTemplate>
<asp:Label ID="lbAnswerGraphicPath" runat="server" />
<asp:LinkButton CommandName="UpdateAnswerGraphic" cssclass='login' Runat='server' ID="lbAddGraphic">Update Answer Graphic</asp:LinkButton>
</EditItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid><br />
</td>
</tr>
Whenever a user selects something from the first grid it triggers an itemcommand in which I can get the graphic ID of the row.
I want to be able to then add text to the label of the second grid "lbAnswerGraphicPath" and close the window for this first grid.
My problem is that I cannot seem to access the rg_Answers label "lbAnswerGraphicPath" from within the rg_graphics.ItemCommand event.
I have tried this code:
For Each item As GridDataItem In rg_Answers.Items
Dim TestLabel As Label = DirectCast(item("AnswerGraphicColumn").FindControl("lbAnswerGraphicPath"), Label)
Next
However the TestLabel object always returns as nothing. How can I access this label (and change the text within) from the rg_graphics.itemcommand event?
<telerik:radwindow runat="server" id="rwGraphics" visibleonpageload="false">
<ContentTemplate>
<asp:UpdatePanel ID="Updatepanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Literal ID="GraphicType" runat="server" Visible="false" />
<asp:Literal ID="CurrentID" runat="server" Visible="false" />
<asp:Literal ID="litJS" Runat="server"/>
<div align='center'>
<table width='300' cellpadding='0' >
<tr>
<td width='100%' colspan="3" align='left'>
<telerik:RadGrid ID="rg_graphics" runat="server" AllowSorting="true" AutoGenerateColumns="false" Width="100%" GridLines="Both"
BorderStyle="None" ShowFooter="false" ShowHeader="true" AlternatingItemStyle-BackColor="WhiteSmoke" AllowAutomaticInserts="false" restrictionzoneId="ContentTemplateZone" >
<HeaderStyle BackColor="#000084" Font-Bold="true" ForeColor="White" HorizontalAlign='left' />
<MasterTableView OverrideDataSourceControlSorting="true" DataKeyNames="GraphicId" ShowHeader="false" >
<Columns>
<telerik:GridButtonColumn ItemStyle-Wrap="false" CommandName="AddGraphic" ButtonType="LinkButton" Text="Add File" />
</Columns>
<ItemTemplate >
<asp:hyperlink runat='server' id='hl_graphic' Target='_blank' CssClass='login' navigateurl='<%#getGraphicPath(DataBinder.Eval(Container.DataItem, "GraphicID"))%>'><%#DataBinder.Eval(Container.DataItem, "Description")%></asp:hyperlink>
</ItemTemplate>
</MasterTableView>
</telerik:RadGrid><br />
<asp:Label ID='l_noresults' Runat='server'><font color='firebrick'><b>No Graphics Found</b></font></asp:Label>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</telerik:radwindow>
The next grid is what calls the first grid.
<tr>
<td class="RightAlignHeader" width="1%" nowrap="nowrap">Answers</td>
<td>
<telerik:RadGrid ID="rg_Answers" runat="server" AllowSorting="true" AutoGenerateColumns="false" Width="100%" GridLines="Both"
BorderStyle="None" ShowFooter="false" ShowHeader="true" AlternatingItemStyle-BackColor="WhiteSmoke" AllowAutomaticInserts="false" >
<HeaderStyle BackColor="#000084" Font-Bold="true" ForeColor="White" HorizontalAlign='left' />
<MasterTableView OverrideDataSourceControlSorting="true" CommandItemDisplay="Top" AllowSorting="true" DataKeyNames="AnswerId" ShowHeadersWhenNoRecords="true" CommandItemSettings-AddNewRecordText="Add New Answer">
<Columns>
<telerik:GridButtonColumn UniqueName="btnDelete" Text="Delete" ConfirmText="Confirm delete?" ButtonType="LinkButton" CommandName="Delete" ItemStyle-Width="1%" />
<telerik:GridButtonColumn UniqueName="btnEdit" Text="Edit" ButtonType="LinkButton" CommandName="Edit" ItemStyle-Width="1%" />
<telerik:GridBoundColumn UniqueName="Text" DataField="Text" HeaderText="Answers" ItemStyle-Wrap="false" SortExpression="Text"/>
<telerik:GridCheckBoxColumn UniqueName="IsCorrect" DataField="IsCorrect" HeaderText="Correct" SortExpression="IsCorrect" DefaultInsertValue="False" />
<telerik:GridImageColumn UniqueName="AnswerGraphic" HeaderText="Graphic"/>
<telerik:GridTemplateColumn Display="false" UniqueName="AnswerGraphicColumn" >
<EditItemTemplate>
<asp:Label ID="lbAnswerGraphicPath" runat="server" />
<asp:LinkButton CommandName="UpdateAnswerGraphic" cssclass='login' Runat='server' ID="lbAddGraphic">Update Answer Graphic</asp:LinkButton>
</EditItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid><br />
</td>
</tr>
Whenever a user selects something from the first grid it triggers an itemcommand in which I can get the graphic ID of the row.
I want to be able to then add text to the label of the second grid "lbAnswerGraphicPath" and close the window for this first grid.
My problem is that I cannot seem to access the rg_Answers label "lbAnswerGraphicPath" from within the rg_graphics.ItemCommand event.
I have tried this code:
For Each item As GridDataItem In rg_Answers.Items
Dim TestLabel As Label = DirectCast(item("AnswerGraphicColumn").FindControl("lbAnswerGraphicPath"), Label)
Next
However the TestLabel object always returns as nothing. How can I access this label (and change the text within) from the rg_graphics.itemcommand event?