RadGrid popupModal another radgrid

5 posts, 0 answers
  1. Shehab
    Shehab avatar
    48 posts
    Member since:
    Nov 2007

    Posted 14 Aug 2008 Link to this post

    Hi All,

    I want to define a radgrid in a template inside another radgrid so when I click on the modalpopbutton it fires up the second datagrid inside the panel;

    <radG:RadGrid ID="rgDep" runat="server" AutoGenerateColumns="False" GridLines="None" Skin="WebBlue" AllowSorting="True" EnableAJAX="True">  
                            <MasterTableView> 
                                <Columns> 
                                      <radG:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Contact">  
                                          <ItemTemplate>                         
                                            <asp:LinkButton ID="btnShowDetails" runat="server" CausesValidation="false" Text='<%# Eval("Contact") %>'>  
                                            </asp:LinkButton>    
                                            <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="pDepDetails" 
                                            OkControlID="btnOK" TargetControlID="btnShowDetails" BackgroundCssClass="modalBackground" DropShadow="true">  
                                            </cc1:ModalPopupExtender>                        
                                              <asp:Panel ID="pDepDetails" runat="server" BackColor="Beige" Font-Bold="True" style="display: none">  
                                                  <asp:Label ID="lblDepID" runat="server" Text='<%# Eval("ContactID") %>'></asp:Label> 
                                                  <br /> 
                                                  <table> 
                                                      <tr> 
                                                          <td style="width: 100px">  
                                                              <img src="Images/a.gif" style="width: 25px; height: 18px" /><span style="font-size: 10pt"><strong>Aultman  
                                                                  Hospital Phone Book</strong></span></td> 
                                                      </tr> 
                                                      <tr> 
                                                          <td style="width: 100px">  
                                                  <radG:RadGrid ID="rgDepDetails" runat="server" AutoGenerateColumns="False" GridLines="None" 
                                                      Skin="WebBlue" OnNeedDataSource="rgDepDetails_NeedDataSource">  
                                                      <MasterTableView> 
                                                          <Columns> 
                                                              <radG:GridBoundColumn DataField="Contact" HeaderText="Department" ReadOnly="True" UniqueName="Contact">  
                                                              </radG:GridBoundColumn> 
                                                              <radG:GridBoundColumn DataField="Ext" HeaderText="Extension" ReadOnly="True" UniqueName="Ext">  
                                                              </radG:GridBoundColumn> 
                                                              <radG:GridBoundColumn DataField="Pager" HeaderText="Pager" UniqueName="Pager">  
                                                              </radG:GridBoundColumn> 
                                                              <radG:GridBoundColumn DataField="Office" HeaderText="Office" UniqueName="Office">  
                                                              </radG:GridBoundColumn> 
                                                              <radG:GridBoundColumn DataField="Fax" HeaderText="Fax" UniqueName="Fax">  
                                                              </radG:GridBoundColumn> 
                                                              <radG:GridBoundColumn DataField="IP" HeaderText="IP" UniqueName="IP">  
                                                              </radG:GridBoundColumn> 
                                                          </Columns> 
                                                          <RowIndicatorColumn Visible="False">  
                                                              <HeaderStyle Width="20px" /> 
                                                          </RowIndicatorColumn> 
                                                          <ExpandCollapseColumn Visible="False">  
                                                              <HeaderStyle Width="19px" /> 
                                                          </ExpandCollapseColumn> 
                                                      </MasterTableView> 
                                                  </radG:RadGrid></td>  
                                                      </tr> 
                                                  </table> 
                                                  <br /> 
                                              </asp:Panel> 
                                          </ItemTemplate> 
                                      </radG:GridTemplateColumn> 
                                      <radG:GridBoundColumn DataField="Contact" HeaderText="Department" ReadOnly="True" UniqueName="Contact">  
                                      </radG:GridBoundColumn> 
                                      <radG:GridBoundColumn DataField="Ext" HeaderText="Extension" ReadOnly="True" UniqueName="Ext">  
                                      </radG:GridBoundColumn> 
                                      <radG:GridBoundColumn DataField="Pager" HeaderText="Pager" UniqueName="Pager">  
                                      </radG:GridBoundColumn> 
                                      <radG:GridBoundColumn DataField="Office" HeaderText="Office" UniqueName="Office">  
                                      </radG:GridBoundColumn> 
                                      <radG:GridBoundColumn DataField="Fax" HeaderText="Fax" UniqueName="Fax">  
                                      </radG:GridBoundColumn> 
                                      <radG:GridBoundColumn DataField="IP" HeaderText="IP" UniqueName="IP">  
                                      </radG:GridBoundColumn>          
                                </Columns> 
                                <RowIndicatorColumn Visible="False">  
                                    <HeaderStyle Width="20px" /> 
                                </RowIndicatorColumn> 
                                <ExpandCollapseColumn Visible="False">  
                                    <HeaderStyle Width="19px" /> 
                                </ExpandCollapseColumn> 
                            </MasterTableView> 
                        </radG:RadGrid> 
    I was thinking to do inside the Itemdatabound of the first radgrid.;
    Dim rgdepdetails As Telerik.WebControls.RadGrid = DirectCast(rgDep.Items(0).FindControl("rgDepDetails"), RadGrid)  
     
    It throws an out of range error.

    Any Ideas?

    Thanks,
    Shehab
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 14 Aug 2008 Link to this post

    Hi Shehab,

    In ItemDataBound you can use e.Item instead Items collection.

    All the best,
    Vlad
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shehab
    Shehab avatar
    48 posts
    Member since:
    Nov 2007

    Posted 14 Aug 2008 Link to this post

    Thank you very much,

    Now, I am getting Object reference not set to an instance of an Object;
        Protected Sub rgDep_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.WebControls.GridItemEventArgs) Handles rgDep.ItemDataBound  
            Dim dataRow As DataRowView = CType(e.Item.DataItem, DataRowView)  
            Dim getDS As New DataSet  
            'Dim rgdepdetails As Telerik.WebControls.RadGrid = DirectCast(rgDep.Items(0).FindControl("rgDepDetails"), RadGrid)  
            If TypeOf e.Item Is GridDataItem Then 
                Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)  
                Dim rgdepdetails As RadGrid = CType(item.GetDataKeyValue("rgDepDetails"), RadGrid)  
                getDS = dataConn.PhoneSearchDep(txtSearch.Text)  
                rgdepdetails.DataSource = getDS  
            End If 
        End Sub 
    and it wouldn't work if I add rgdepdetails to the keydatamember.

    Thanks again.
  5. Sean
    Sean  avatar
    54 posts
    Member since:
    Apr 2008

    Posted 14 Aug 2008 Link to this post

    Which line is it failing on? If it is th efirst line, I suggesst moving

    Dim
     dataRow As DataRowView = CType(e.Item.DataItem, DataRowView)  

    inside of your IF block. The dataitem does not exist for header rows, I beleieve.

    Thanks for listening.

    Sean
    Electronic Arts, Orlando FL
  6. Shehab
    Shehab avatar
    48 posts
    Member since:
    Nov 2007

    Posted 14 Aug 2008 Link to this post

    Hi Sean,

    Thank you for the reply, it fails in the line;
    rgdepdetails.DataSource = getDS 
    where it assigns the datasource, I also tried to just do anything to the radgrid as set it to visible for example and it gives the same error.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017