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

RadGrid popupModal another radgrid

4 Answers 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shehab
Top achievements
Rank 1
Shehab asked on 14 Aug 2008, 03:20 PM
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

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 14 Aug 2008, 03:24 PM
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.
0
Shehab
Top achievements
Rank 1
answered on 14 Aug 2008, 04:55 PM
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.
0
Sean
Top achievements
Rank 2
answered on 14 Aug 2008, 05:28 PM
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
0
Shehab
Top achievements
Rank 1
answered on 14 Aug 2008, 05:39 PM
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.
Tags
Grid
Asked by
Shehab
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Shehab
Top achievements
Rank 1
Sean
Top achievements
Rank 2
Share this question
or