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

childgrid not being displayed

1 Answer 51 Views
Grid
This is a migrated thread and some comments may be shown as answers.
aditi
Top achievements
Rank 1
aditi asked on 24 Oct 2008, 03:27 PM

Hi,
I am using radcontrols with .net1.1 in VS2003. I want to display mastergrid and on clicking a plus sign, a child grid.I have written a simple code for this. But I cannot see the chidgrid on compiling and running the project.I cannot see even the header names of the childgrid. when I click on the '+' sign,it just refreshes the page but show even the headers.
And also I an needdatasource and detaildatabind handlers in the initialize method. But when I use breakpoint to check the flow, the events are not happening. Its just executing FillGridData and nothing else.

Can any one tel me whats happennig?

Following is my code in aspx and cs

<%@ Register TagPrefix="rada" Namespace="Telerik.WebControls" Assembly="RadAjax" %>
<%@ Register TagPrefix="radM" Assembly="RadMenu" Namespace="Telerik.WebControls" %>
<%@ Register TagPrefix="radcb" Namespace="Telerik.WebControls" Assembly="RadComboBox" %>
<%@ Register TagPrefix="ignav1" Namespace="Infragistics.WebUI.UltraWebNavigator" Assembly="Infragistics.WebUI.UltraWebNavigator.v3.2, Version=3.2.20042.26, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" %>
<%@ Register TagPrefix="radW" Namespace="Telerik.WebControls" Assembly="RadWindow" %>
<%@ Register TagPrefix="radG" Namespace="Telerik.WebControls" Assembly="RadGrid" %>
<%@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="Vortex.Log.WebForm2" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>
  <title>WebForm2</title>
  <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
  <meta name="CODE_LANGUAGE" Content="C#">
  <meta name="vs_defaultClientScript" content="JavaScript">
  <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
  </HEAD>
 <body MS_POSITIONING="GridLayout">
  <form id="Form1" method="post" runat="server">
   <radG:RadGrid id="RadGrid1" runat="server" autogeneratecolumns="false" EnableAJAX="True">
    <mastertableview datakeynames="USERACTIVITYID">
    <ExpandCollapseColumn Resizable="False">

                                        <HeaderStyle Width="20px"></HeaderStyle>

                                    </ExpandCollapseColumn>

     <Columns>
      <radg:GridBoundColumn Uniquename="USERACTIVITYID" DataField="USERACTIVITYID" visible="false"></radg:GridBoundColumn>
      <radg:GridBoundColumn Uniquename="FNAME" HeaderText="First Name" DataField="FNAME"></radg:GridBoundColumn>
      <radg:GridBoundColumn Uniquename="LNAME" HeaderText="Last Name" DataField="LNAME"></radg:GridBoundColumn>
      <radg:GridBoundColumn Uniquename="LOGINTIME" HeaderText="Login Time" DataField="LOGINTIME"></radg:GridBoundColumn>
      <radg:GridBoundColumn Uniquename="LOGOUTTIME" HeaderText="Logout Time" DataField="LOGOUTTIME"></radg:GridBoundColumn>
      <radg:GridBoundColumn Uniquename="IPADDRESS" HeaderText="Client IP" DataField="IPADDRESS"></radg:GridBoundColumn>
      <radg:GridBoundColumn Uniquename="MARKET" HeaderText="Market" DataField="MARKET"></radg:GridBoundColumn>
     </Columns>
     
     <DetailTables>
     <radg:GridTableView  datakeynames="USERACTIVITYID">
       <Columns>
       <radg:GridBoundColumn Uniquename="USERACTIVITYID" DataField="USERACTIVITYID" visible="false"></radg:GridBoundColumn>
        <radg:GridBoundColumn Uniquename="FNAME" HeaderText="TYPE" DataField="FNAME"></radg:GridBoundColumn>
        <radg:GridBoundColumn Uniquename="LOGINTIME" HeaderText="LOGINTIME" DataField="LOGINTIME"></radg:GridBoundColumn>
        <radg:GridBoundColumn Uniquename="LOGOUTTIME" HeaderText="Action Time" DataField="LOGOUTTIME"></radg:GridBoundColumn>
       </Columns>
      </radg:GridTableView>
     </DetailTables>
    </mastertableview>
               
   </radG:RadGrid>
  </form>
 </body>
</HTML>

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Vortex.Log
{
 /// <summary>
 /// Summary description for WebForm2.
 /// </summary>
 public class WebForm2 : System.Web.UI.Page
 {
  protected Telerik.WebControls.RadGrid RadGrid1;
  private AllLogsData1 ald = new AllLogsData1();
 
  private void Page_Load(object sender, System.EventArgs e)
  {
   // Put user code to initialize the page here
   if(! IsPostBack)
   {
    if(ald.getAllData(Session["userid"].ToString(), Session["usertypeid"].ToString(),Session["userid"].ToString()))
     FillGridData();
    
   }
  }

  private void FillGridData()
  {
   RadGrid1.DataSource=ald.dataSource.Tables["session"].DefaultView;
   RadGrid1.DataBind();
  
   
  }

  #region Web Form Designer generated code
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: This call is required by the ASP.NET Web Form Designer.
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// Required method for Designer support - do not modify
  /// the contents of this method with the code editor.
  /// </summary>
  private void InitializeComponent()
  {   
   this.Load += new System.EventHandler(this.Page_Load);
   this.RadGrid1.NeedDataSource+= new Telerik.WebControls.GridNeedDataSourceEventHandler(this.RadGrid1_NeedDataSource);
   this.RadGrid1.DetailTableDataBind+=new Telerik.WebControls.GridDetailTableDataBindEventHandler(this.RadGrid1_DetailTableDataBind);

  }
  
  protected void RadGrid1_NeedDataSource(object source, Telerik.WebControls.GridNeedDataSourceEventArgs e)
  {
   RadGrid1.DataSource=ald.dataSource.Tables["session"];
   
  }
  
  

  protected void RadGrid1_DetailTableDataBind(object source, Telerik.WebControls.GridDetailTableDataBindEventArgs e)
  {
   RadGrid1.DataSource=ald.dataSource.Tables["session"];
  }

  #endregion
 }
}

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 27 Oct 2008, 04:10 PM
Hi aditi,

Please review the below articles for more information about RadGrid hierarchy and hierarchy data-binding:

http://www.telerik.com/help/aspnet/grid/grdunderstandinghierarchy.html
http://demos.telerik.com/aspnet/Grid/Examples/Programming/DetailTableDataBind/DefaultCS.aspx
http://www.telerik.com/help/aspnet/grid/grdhierarchicaldatabindingusingdetailtabledatabind.html

Check if you have followed the steps described there and let me know if any issues arise.

Regards,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
aditi
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or