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

Details table not refreshed in spite of DetailTableDataBind is fired

10 Answers 237 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Leonardo
Top achievements
Rank 1
Leonardo asked on 27 Jan 2011, 07:59 PM
Hi,
 I have a grid  (Version Q3 2009 NET35 -  Product Version:  2009.3.1314.35 - Telerik.Web.UI.dll ) with one master table and two detail tables (One inside the other one).  The details table are populated dynamically when the 
row is selected.  First time that the page runs the master table and the detail tables are populated properly.   The user selects one row 
from the master table and the data to populate the detail table is retreived from the database at that moment and the grid displays fine. 

If the user changes the search criteria for the report and hits the "Search button" the grid is refreshed (A Post back is fired). 
Master table is refreshed properly based on the new search criteria. When the detail grid is opened is still showing the data from the previous execution

The "DetailTableDataBind" event is fired.  The data used to populate the detail grid is retreived fine. The datasource for the
DetailTableView is linked to the datatable, but for any reason the  page rendered is still showing the old data.

A sample of the code is attached to make the question more understandable. 

<telerik:RadGrid ID="mkgtTotalLevels" runat="server" Skin="Outlook" OnItemDataBound="mkgtTotalLevels_ItemDataBound"
 OnNeedDataSource="mkgtTotalLevels_NeedDataSource" ondetailtabledatabind="mkgtTotalLevels_DetailTableDataBind"
 OnItemCommand="mkgtTotalLevels_ItemCommand" DataSourcePersistenceMode="NoPersistence"
 AllowPaging="True" AllowSorting="true" PageSize="20" HeaderStyle-Font-Bold="true"
 Width="100%" AutoGenerateColumns="true">
 
 <MasterTableView Name="Level1" DataKeyNames="MarketingSourceID" CommandItemDisplay="Top">
 
  <DetailTables>
   <telerik:GridTableView Name="Level2" DataKeyNames="MarketingSourceSubID" CommandItemDisplay="Top" HierarchyLoadMode="ServerOnDemand"
                AutoGenerateColumns="true"  Width="100%" BackColor="#EFEFFB" >

    <DetailTables>
     <telerik:GridTableView Name="Level3" DataKeyNames="" CommandItemDisplay="Top" HierarchyLoadMode="ServerOnDemand"
      AutoGenerateColumns="true"  Width="100%" BackColor="#FFFFCC" >     
     </telerik:GridTableView>                                                       
                </DetailTables>
                                                   
            </telerik:GridTableView>
  </DetailTables>                                           
 </MasterTableView>      
 
 
 ==============================================================================================
 
 
protected void mkgtTotalLevels_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
 BindDataGrid();
}

private void BindDataGrid()
{                       
 SetRangeDates();

 SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TargetInfoNetConnectionString"].ConnectionString);

 try
 {
  // Get a Pivot table with the Marketing Level 1 - Total of Providers
  string str = "dbo.spPivot_MkgtLevel1_Totals";
  SqlCommand cmd = new SqlCommand(str, con);
  cmd.CommandType = CommandType.StoredProcedure;

  cmd.Parameters.Add("@DateFrom", SqlDbType.Date);
  cmd.Parameters["@DateFrom"].Value = StartDate;

  cmd.Parameters.Add("@DateTo", SqlDbType.Date);
  cmd.Parameters["@DateTo"].Value = EndDate;

  SqlDataAdapter da = new SqlDataAdapter(cmd);
  DataTable dt = new DataTable();
  da.Fill(dt);
  
  mkgtTotalLevels.DataSource = dt;               
 }

 finally
 {
  con.Close();
 }
}

protected void mkgtTotalLevels_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
 GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;

 //**** Level 2 ****
 if (e.DetailTableView.Name == "Level2")
 {
  DataTable dt2 = new DataTable();
  Int32 Level1 = 0;
  Int32.TryParse(dataItem.GetDataKeyValue("MarketingSourceID").ToString(), out Level1);
   
  dt2 = GetLevel2Data(Level1);
      
  e.DetailTableView.DataSource = dt2;               
 }

 //**** Level 3 ****
 if (e.DetailTableView.Name == "Level3")
 {
  DataTable dt3 = new DataTable();
  Int32 Level2 = 0;
  Int32.TryParse(dataItem.GetDataKeyValue("MarketingSourceSubID").ToString(), out Level2);
  
  dt3 = GetLevel3Data(Level2);
  e.DetailTableView.DataSource = dt3;
 }
}

private DataTable GetLevel2Data(int Level1)
{
 DataTable dt = new DataTable();

 SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TargetInfoNetConnectionString"].ConnectionString);

 try
 {
  SetRangeDates();
  // Get a Pivot table with the Marketing Level 2 - Total of Providers
  string str = "dbo.spPivot_MkgtLevel2_Totals";
  SqlCommand cmd = new SqlCommand(str, con);
  cmd.CommandType = CommandType.StoredProcedure;

  cmd.Parameters.Add("@DateFrom", SqlDbType.Date);
  cmd.Parameters["@DateFrom"].Value = StartDate;

  cmd.Parameters.Add("@DateTo", SqlDbType.Date);
  cmd.Parameters["@DateTo"].Value = EndDate;

  cmd.Parameters.Add("@MarketingSourceID", SqlDbType.Int);
  cmd.Parameters["@MarketingSourceID"].Value = Level1;

  SqlDataAdapter da = new SqlDataAdapter(cmd);
  
  da.Fill(dt);

  return dt;
 }

 finally
 {
  con.Close();
 }
}

private DataTable GetLevel3Data(int Level2)
{
 DataTable dt = new DataTable();
 SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TargetInfoNetConnectionString"].ConnectionString);

 try
 {
  SetRangeDates();

  // Get a Pivot table with the Marketing Level 3 - Total of Providers
  string str = "dbo.spPivot_MkgtLevel3_Totals";
  SqlCommand cmd = new SqlCommand(str, con);
  cmd.CommandType = CommandType.StoredProcedure;

  cmd.Parameters.Add("@DateFrom", SqlDbType.Date);
  cmd.Parameters["@DateFrom"].Value = StartDate;

  cmd.Parameters.Add("@DateTo", SqlDbType.Date);
  cmd.Parameters["@DateTo"].Value = EndDate;

  cmd.Parameters.Add("@MarketingSourceSubID", SqlDbType.Int);
  cmd.Parameters["@MarketingSourceSubID"].Value = Level2;

  SqlDataAdapter da = new SqlDataAdapter(cmd);

  da.Fill(dt);

  return dt;
 }

 finally
 {
  con.Close();
 }
}

private void SetRangeDates()
{
 DateTime tmpDate;
 int intYear = 0;
 int intMonth = 0;
 int intDay = 0;

 // **** Start Date ****
 intYear = int.Parse(ddlFromYear.SelectedValue.ToString());
 intMonth = int.Parse(ddlFromMonth.SelectedValue.ToString());
 intDay = 1;

 tmpDate = new DateTime(intYear, intMonth, intDay);
 StartDate = tmpDate;

 // **** End Date ****
 intYear = int.Parse(ddlToYear.SelectedValue.ToString());
 intMonth = int.Parse(ddlToMonth.SelectedValue.ToString());
 tmpDate = new DateTime(intYear, intMonth, 1);
 tmpDate = tmpDate.AddMonths(1);
 tmpDate = tmpDate.AddDays(-1);
 intDay = tmpDate.Day;
 tmpDate = new DateTime(intYear, intMonth, intDay);
 EndDate = tmpDate;
}

 




 

 

10 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 01 Feb 2011, 03:17 PM
Hello Leonardo,

Could you please confirm if you use ajax in this scenario? If there is an ajax manager, you should add a setting where the grid updates itself, so that the client output of the control is refreshed after the callback.

Regards,
Tsvetina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Leonardo
Top achievements
Rank 1
answered on 02 Feb 2011, 04:36 PM
Hi Tsvetina,

I created a Web Content Form and I realized the master page contains a Rad Ajax Manager.  You mentioned
a setting that needs to be added to the grid;  Could you please tell me the setting or attribute that needs to be added?

Kind Regards,

Leonardo.
0
Tsvetina
Telerik team
answered on 07 Feb 2011, 08:53 AM
Hello Leonardo,

If the grid updates through an ajax request, you should have a setting where the grid updates itself. If it is in a content page and the manager is in the master page, you should use a RadAjaxManagerProxy:
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
   <AjaxSettings>
       <telerik:AjaxSetting AjaxControlID="RadGrid1">
           <UpdatedControls>
               <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
           </UpdatedControls>
       </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>


Kind regards,
Tsvetina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Leonardo
Top achievements
Rank 1
answered on 09 Feb 2011, 08:31 PM
Hi Tsvetina,  In spite of I am using the code (RadAjaxManagerProxy1) that you suggested, the issue is still there.


I decided to send you the HTML code.  Maybe you can take a look to the Grid attributes and see if something
is still mising.

Please let me know if you want me to send you to code behind.


Thanks,

Leonardo.



===================================================================================================== 

<%@ Page Language="C#" MasterPageFile="~/CommonSecurity/MasterPages/TopBottomWithControls.Master" AutoEventWireup="true" CodeBehind="marketingTotalLevelsExport.aspx.cs" Inherits="HPPInfoNet.Reports.marketingTotalLevelsExport" Title="Marketing Total Levels" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphCenter" runat="server">   
    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="mkgtTotalLevels">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="mkgtTotalLevels" />                                       
                </UpdatedControls>           
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>   

    <fieldset>
        <legend><font color="blue"><b>REPORTS ==&gt; Marketing Total Levels Export</b></font></legend>
        <br />
        <table style="width:100%;" border="0">
            <%--**** Row 1 ****--%>
            <tr>
                <td width="5%">
                    &nbsp;
                </td>
               
                <td colspan="3">
                    <%--**** Search Criteria ****--%>
                   
                    <table style="width:100%">                       
                        <%--**** marketing Source Date ****--%>
                        <tr>
                            <td class="td_AEV" colspan="2">
                                Marketing Source Date:
                            </td>
                        </tr>
                       
                        <tr>
                            <td class="td_AEV" style="width:15%;">
                                from:
                            </td>
                            <td class="td_AEVNoBold">
                                <asp:DropDownList ID="ddlFromYear" Width="100px" runat="server">
                                </asp:DropDownList>
                                &nbsp;
                                <asp:DropDownList ID="ddlFromMonth" Width="100px" runat="server">
                                </asp:DropDownList>
                                &nbsp;&nbsp;<asp:Label ID="lblMessageSourceDates" ForeColor="red" runat="server" Text=""></asp:Label>                              
                            </td>
                        </tr>                       
                       
                        <tr>
                            <td class="td_AEV" style="width:15%;">
                                to:
                            </td>
                            <td class="td_AEVNoBold">
                                <asp:DropDownList ID="ddlToYear" Width="100px" runat="server">
                                </asp:DropDownList>
                                &nbsp;
                                <asp:DropDownList ID="ddlToMonth" Width="100px" runat="server">
                                </asp:DropDownList>
                            </td>
                        </tr>   
                        <tr>
                            <td class="td_AEV" colspan="2" align="center">
                                <asp:Button ID="btnSearch" runat="server" Text="Search"
                                    OnClick="btnSearch_Click" Font-Bold="true" Width="200px" />
                            </td>
                        </tr>                       
                    </table>
                </td>
                               
                <td width="5%">               
                    &nbsp;
                </td>               
            </tr>
               
            <%--**** Grid - Results ****--%>
            <tr valign="top">
                <td width="5%">
                    &nbsp;
                </td>
               
                <td colspan="3">
                    <asp:Panel ID="pnlResults" runat="server">                   
                         <fieldset>
                        <legend><font color="blue"><b>Search Results</b></font></legend>
                        <table width="100%" cellpadding="0" cellspacing="0" border="0">
                            <tr>
                                <td align="right" width="100%">
                                   <asp:ImageButton ID="excelExport" ImageUrl="~/images/excel_icon_16x16.gif" runat="server"
                                        OnClick="excelExport_Click" />
                                    &nbsp; <b>Export Raw Data</b>
                                </td>
                            </tr>
                            <tr>
                                <td class="td_AEVNoBold">
                                    <telerik:RadGrid ID="mkgtTotalLevels" runat="server" Skin="Outlook" OnItemDataBound="mkgtTotalLevels_ItemDataBound"
                                        OnNeedDataSource="mkgtTotalLevels_NeedDataSource" ondetailtabledatabind="mkgtTotalLevels_DetailTableDataBind"
                                        OnItemCommand="mkgtTotalLevels_ItemCommand"
                                        AllowPaging="True" AllowSorting="true" PageSize="20" HeaderStyle-Font-Bold="true"
                                        Width="100%" AutoGenerateColumns="true">
                                       
                                        <%--**** Level 1 ****--%>
                                        <MasterTableView Name="Level1" DataKeyNames="MarketingSourceID" CommandItemDisplay="Top">                                                                                                                                    
                                           <CommandItemTemplate>
                                                <table style="width:100%" border="0" cellpadding="0" cellspacing="0">
                                                    <tr>
                                                        <td>
                                                            <asp:ImageButton ID="excelExportLevel1" CommandName="ExportLevel1" OnClick="excelExportLevel1_Click"
                                                                ImageUrl="~/images/excel_icon_16x16.gif" runat="server"/>   
                                                            &nbsp;
                                                            <asp:Label ID="lblExportLevel1" runat="server" ForeColor="White" Text="Export Level 1 Data"></asp:Label>
                                                        </td>
                                                        <td>
                                                            &nbsp;
                                                        </td>
                                                    </tr>
                                                </table>
                                            </CommandItemTemplate>                                        
                                                                               
                                             <%--**** Level 2 ****--%>
                                             <DetailTables>                                               
                                                <telerik:GridTableView Name="Level2" DataKeyNames="MarketingSourceSubID" CommandItemDisplay="Top"
                                                    AutoGenerateColumns="true"  Width="100%" BackColor="#EFEFFB" >
                                                        <CommandItemTemplate>
                                                            <table style="width:100%" border="0" cellpadding="0" cellspacing="0">
                                                                <tr>
                                                                    <td>
                                                                        <asp:ImageButton ID="excelExportLevel2" CommandName="ExportLevel2" OnClick="excelExportLevel2_Click"
                                                                            ImageUrl="~/images/excel_icon_16x16.gif" runat="server"/>   
                                                                        &nbsp;
                                                                        <asp:Label ID="lblExportLevel2" runat="server" ForeColor="White" Text="Export Level 2 Data"></asp:Label>
                                                                    </td>
                                                                    <td>
                                                                        &nbsp;
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </CommandItemTemplate>
                                                                                                                                                                  
                                                        <%--**** Level 3 ****--%>
                                                        <DetailTables>
                                                            <telerik:GridTableView Name="Level3" DataKeyNames="" CommandItemDisplay="Top"
                                                                AutoGenerateColumns="true"  Width="100%" BackColor="#FFFFCC" >
                                                                   <CommandItemTemplate>
                                                                        <table style="width:100%" border="0" cellpadding="0" cellspacing="0">
                                                                            <tr>
                                                                                <td>
                                                                                    <asp:ImageButton ID="excelExportLevel3" CommandName="ExportLevel2" OnClick="excelExportLevel3_Click"
                                                                                        ImageUrl="~/images/excel_icon_16x16.gif" runat="server"/>   
                                                                                    &nbsp;
                                                                                    <asp:Label ID="lblExportLevel3" runat="server" ForeColor="White" Text="Export Level 3 Data"></asp:Label>
                                                                                </td>
                                                                                <td>
                                                                                    &nbsp;
                                                                                </td>
                                                                            </tr>
                                                                        </table>
                                                                    </CommandItemTemplate>                                                                 
                                                            </telerik:GridTableView>                                                       
                                                        </DetailTables>
                                                   
                                                </telerik:GridTableView>
                                             </DetailTables>                                           
                                        </MasterTableView>

                                        <HeaderStyle Font-Bold="True"></HeaderStyle>

                                        <%--<ClientSettings EnableRowHoverStyle="true">
                                             <ClientEvents OnPopUpShowing="PopUpShowing" />
                                        </ClientSettings>--%>
                                    </telerik:RadGrid>
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                    </asp:Panel>
                </td>
               
                <td width="5%">
                    &nbsp;
                </td>
            </tr>           
                                 
        </table> 
    </fieldset> 
</asp:Content>

0
Tsvetina
Telerik team
answered on 15 Feb 2011, 09:19 AM
Hello Leonardo,

Try by adding also a setting where the button outside of the grid updates it:

<AjaxSettings
   <telerik:AjaxSetting AjaxControlID="btnSearch"
       <UpdatedControls
           <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
       </UpdatedControls
   </telerik:AjaxSetting
</AjaxSettings


Kind regards,
Tsvetina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Leonardo
Top achievements
Rank 1
answered on 15 Feb 2011, 02:58 PM
Hi Tsvetina,

I did the changes, but I am still getting the same issue.


------------------------------------------------------------------------------------------------

 

<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">

 

 

 

<AjaxSettings>

 

 

<telerik:AjaxSetting AjaxControlID="btnSearch">

 

 

<UpdatedControls>

 

 

<telerik:AjaxUpdatedControl ControlID="mkgtTotalLevels" />

 

 

 

</UpdatedControls>

 

 

 

</telerik:AjaxSetting>

 

 

</AjaxSettings>

 

 

 

</telerik:RadAjaxManagerProxy>

 

------------------------------------------------------------------------------------------------




Regards,

Leonardo.
0
Tsvetina
Telerik team
answered on 18 Feb 2011, 11:11 AM
Hello Leonardo,

Could you please check if the grid behaves properly without being ajaxified at all, by setting EnableAJAX="False" in the RadAjaxManager declaration in the master page. If this is so, the problem should be in the data passed to the grid in its DetailTableDataBind event since it would not show different data from what it is bound to when it is refreshed on the client for sure (which is so when a full postback happens).

Kind regards,
Tsvetina
the Telerik team
0
Leonardo
Top achievements
Rank 1
answered on 28 Feb 2011, 08:03 PM
Hi Tsvetina,

Instead of using a web content form   (Based on a master page),  I decided to
create a normal web form, and the problem is still there.

Please find attached two files with the screenshots.

The first time that the grid is populated everything works fine.
I am using HierarchyLoadMode="ServerOnDemand" on the master and the
detail grids.   When I click on the row in order to see the 2nd level table, a

"DetailTableDataBind" event is fired and the detail table is populated fine and
the grid is rendered properly. The same happens for the Level 3.

When I change the search criteria and hit the "Search" button again, the
master grid is refreshed properly with the new data, but when I try to see the
Detail tables (Level 2 and Level3), the old data is displayed.

I am not using the Ajax Manager this time, so a full post back of the form is
executed. The second time the same "DetailTableDataBind" event is fired.
I verified that I am getting the datatable properly based on the new search criteria.

This report contains a dynamic number of columns, so each time that the
report is run the number of columns and the header titles are different.

I also tried to use HierarchyLoadMode="ServerBind" on the master
and detail tables, but It did not fix the problem.

Please let me know what part is still missing.

Regards,

Leonardo.

0
Leonardo
Top achievements
Rank 1
answered on 28 Feb 2011, 10:12 PM

Hi Tsvetina,

Finally I resolved the issue by using "NestedViewTemplates".   Anyway the
"DetailTables" could be checked by your team.

I followed the documantation that you have in order to implement the
"NestedViewTemplates" and it worked perfectly well.

Thanks again for your support.


Leonardo.
0
Dheeraj
Top achievements
Rank 1
answered on 06 Sep 2011, 02:09 PM
Hi telerik team,

Is this issue is fixed for detail table data not refreshing ?

~ Thanks
Tags
Grid
Asked by
Leonardo
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Leonardo
Top achievements
Rank 1
Dheeraj
Top achievements
Rank 1
Share this question
or