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

Rad grid hierarchy problem

3 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prasad
Top achievements
Rank 1
Prasad asked on 11 Feb 2012, 03:15 PM
Hi there,

Iam using rad gridview for hierarchy implementation and we are binding the grid using 'Need Datasource event'  and observed everything is working fine for expand/collapse functionality .In the same page we are having external search functionality there we are binding the grid by sending the search criteria(i.e, selected through other asp controls in the same page) to database.But after binding the grid and we are unable to expand the grid parent row.For your reference iam pasting my code here.And aslo iam attaching the screen shots for your reference.Please look into this and as we have a production release scheduled soon.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
  
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterForm.master" CodeFile="AuditTrial.aspx.cs" Inherits="AuditTrial" Title="Specimen Tracking System - Audit Trail" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
   
  
  
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <link rel="Stylesheet" href="StyleSheet.css" type="text/css" />
    <script language="javascript" type="text/javascript">
    changeBackground('audit');
    function CallPrint(strprint) {
        if (strprint != 'No Records Found') {
            getPrint(strprint);
        }
        else {
  
            window.location.reload(true);
        }
    }
  
         
</script>
<table width="760" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
              <tr>
                <td height="5"></td>
              </tr>
              <tr>
                <td align="left" style="border: solid 1px #9ce3ff; padding-left:5px;">
   <!-- Edit Table Start Here --> 
                <table width="750" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="5"></td>
                  </tr>
                  <tr>
                    <td align="left" valign="top">
                    <h3><img src="Images/auditTrial.gif" alt="Specimen Tracking" /></h3>                    </td>
                  </tr>
                  <tr>
                    <td height="2">
                        <table class="style1">
                            <tr>
                                <td height="30px" align="left" class="heading">
                                    Protocol:</td>
                                <td>
                                  <%--<asp:DropDownList ID="ddlProtocol" runat="server" Width="160px" CssClass="dropdown" 
                                      >
                                      <asp:ListItem>Select Protocol</asp:ListItem>
                                  </asp:DropDownList>--%>
                                   <telerik:RadComboBox ID="ddlProtocol" runat="server" Skin="Vista" MarkFirstMatch="true" 
                                           AllowCustomText="true" EmptyMessage="Select Protocol Number">
                                       </telerik:RadComboBox>
                                  </td>
                                <td height="30px" align="left" class="heading">
                                    Institute:</td>
                                <td >
                                  <%--<asp:DropDownList ID="ddlInstituteNumber" runat="server"  
                                         
                                      CssClass="dropdown" Width="160px">
                                      <asp:ListItem>Select Institute</asp:ListItem>
                                  </asp:DropDownList>--%>
                                  <telerik:RadComboBox ID="ddlInstituteNumber" runat="server" Skin="Vista" MarkFirstMatch="true" 
                                           AllowCustomText="true" EmptyMessage="Select Institute Number" >
                                       </telerik:RadComboBox>
                                  </td>
                            </tr>
                            <tr>
                                <td height="30px" align="left" class="heading">
                                    Study Number:</td>
                                <td ">
                                     </td>
                                <td height="30px" align="left" class="heading">
                                  <%--<asp:DropDownList ID="ddlStudyNumber" runat="server"  
                                        
                                      CssClass="dropdown" Width="160px" >
                                      <asp:ListItem>Select Study Number</asp:ListItem>
                                  </asp:DropDownList>--%>
                                   <telerik:RadComboBox ID="ddlStudyNumber" runat="server" 
                                        EmptyMessage="Select Study Number" MarkFirstMatch="true" AllowCustomText="true" 
                                        Skin="Vista"  >
                                       </telerik:RadComboBox>
                                  </td>
                                <td height="30px" align="left" class="heading">
                                   Biopsy Control Number:</td>
                                   <td height="30px" align="left" class="heading">
                                 <%-- <asp:DropDownList ID="ddlBCN" runat="server"  
                                        
                                      CssClass="dropdown" Width="160px" >
                                      <asp:ListItem>Select BCN</asp:ListItem>--%>
                                      <telerik:RadComboBox ID="ddlBCN" runat="server" 
                                           EmptyMessage="Select Biopsy control Number" MarkFirstMatch="true" 
                                           AllowCustomText="true" Skin="Vista" >
                                       </telerik:RadComboBox>
                                  <%--</asp:DropDownList>--%>
                                  </td>
                            </tr>
                            <tr>
                                <td height="30px" align="left" class="heading">
                                    Lab Name:</td>
                                <td>
                                  <%--<asp:DropDownList ID="ddlLabNumber" runat="server"  
                                       
                                      CssClass="dropdown" Width="160px" >
                                      <asp:ListItem>Select Lab Number</asp:ListItem>
                                  </asp:DropDownList>--%>
                                   <telerik:RadComboBox ID="ddlLabNumber" runat="server" Skin="Vista" MarkFirstMatch="true" 
                                           AllowCustomText="true" EmptyMessage="Select Lab Name" >
                                       </telerik:RadComboBox>
                                  </td>
                                <td height="30px" align="left" class="heading">
                                    Specimen Number:</td>
                                <td>
                                  <%--<asp:DropDownList ID="ddlSpecimenNumber" runat="server"  
                                         
                                      CssClass="dropdown" Width="160px">
                                      <asp:ListItem>Select Specimen Number</asp:ListItem>
                                  </asp:DropDownList>--%>
                                   <telerik:RadComboBox ID="ddlSpecimenNumber" runat="server" Skin="Vista" MarkFirstMatch="true" 
                                           AllowCustomText="true" EmptyMessage="Select Specimen Number">
                                       </telerik:RadComboBox>
                                  </td>
                            </tr>
                            <tr>
                               <%-- <td height="30px" align="left" class="heading">
                                    User Name:</td>
                                <td>
                                  <asp:DropDownList ID="ddlUser" runat="server"  
                                        
                                      CssClass="dropdown" Width="160px">
                                      <asp:ListItem>Select User</asp:ListItem>
                                  </asp:DropDownList>
                                  </td>--%>
                                  
                                    <td height="30px" align="left" class="heading">
                                    Specimen Condition:<td>
                                 <%-- <asp:DropDownList ID="ddlSpecimenCondition" runat="server"  
                                        
                                      CssClass="dropdown" Width="185px">
                                      <asp:ListItem>Select Specimen Condition</asp:ListItem>
                                  </asp:DropDownList>--%>
                                   <telerik:RadComboBox ID="ddlSpecimenCondition" runat="server" Skin="Vista" MarkFirstMatch="true" 
                                           AllowCustomText="true" EmptyMessage="Select Specimen Condition">
                                       </telerik:RadComboBox>
                                  </td>
                                   <td height="30px" align="left" class="heading">
                                    Disposal Reason:</td>
                                <td>
                                 <%-- <asp:DropDownList ID="ddlDisposalReason" runat="server"  
                                        
                                      CssClass="dropdown" Width="160px" AutoPostBack="false">
                                      <asp:ListItem>Select Disposal Reason</asp:ListItem>
                                  </asp:DropDownList>--%>
                                   <telerik:RadComboBox ID="ddlDisposalReason" runat="server" Skin="Vista" MarkFirstMatch="true" 
                                           AllowCustomText="true" EmptyMessage="Select Disposal Reason" >
                                       </telerik:RadComboBox>
                                     
                                  </td>
                            </tr>
                            <tr>
                                  
                                    <td height="30px" align="left" class="heading">
                                        Lab Number:</td>
                                     
                                   <td>
                                       <telerik:RadComboBox ID="ddllabname" runat="server" Skin="Vista" MarkFirstMatch="true" 
                                           AllowCustomText="true" EmptyMessage="Select Lab Number" >
                                       </telerik:RadComboBox>
                                   </td>
                                <td>
                                     </td>
                            </tr>
                            <tr>
                                  
                                 <td align="left" class="style2" colspan="4">
                                     Form Block</td>
                                <td class="style3">
                                    </td>
                                  <%--<td  height="30px" align="left" class="heading">
                                       </td>--%>
                                   <td class="style3">
                                       </td>
                            </tr>
                            <tr>
                                  
                                 <td height="30px" align="left" class="heading">
                                     Block  Submission Type:</td>
                                <td>
                                  <%--<asp:DropDownList ID="ddlBlockSubmissionType" runat="server" Visible="true" 
                                        
                                      CssClass="dropdown" Width="180px">
                                      <asp:ListItem>Select Submission Type</asp:ListItem>--%>
                                       <telerik:RadComboBox ID="ddlBlockSubmissionType" runat="server" 
                                        Skin="Vista" MarkFirstMatch="true" 
                                           AllowCustomText="true" EmptyMessage="Select Submission Type">
                                       </telerik:RadComboBox>
                                <%--  </asp:DropDownList>--%>
                                  </td>
                                  <td  height="30px" align="left" class="heading" colspan="2">
                                      Block Type:  <%--<asp:DropDownList ID="ddBlockType" runat="server"  
                                        
                                      CssClass="dropdown" Width="160px" AutoPostBack="false">
                                      <asp:ListItem>Select Block Type</asp:ListItem>
                                      <asp:ListItem Value="DB">Biopsy</asp:ListItem>
                                      <asp:ListItem Value="PT">Primary Tumor</asp:ListItem>
                                      <asp:ListItem Value="LN">Lymph Node</asp:ListItem>
                                  </asp:DropDownList>--%>
                                   <telerik:RadComboBox ID="ddBlockType" runat="server" Skin="Vista" MarkFirstMatch="true" 
                                           AllowCustomText="true" EmptyMessage="Select Block Type">
                                   <Items>
                                   <telerik:RadComboBoxItem Text="Select Block Type" value="" />
                                   <telerik:RadComboBoxItem Text="Biopsy" value="DB" />
                                   <telerik:RadComboBoxItem Text="Primary Tumor" value="PT" />
                                   <telerik:RadComboBoxItem Text="Lymph Node" value="LN" />
                                   </Items>
                                       </telerik:RadComboBox>
                                  </td>
                                   <td align="left">
                                    
                                     
                                  </td>
                            </tr>
                            <tr>
                                  
                                 <td height="30px" align="left" class="heading">
                                     Field Name:</td>
                                <td>
                                  <%--<asp:DropDownList ID="ddlFielsName" runat="server" Visible="true" 
                                        
                                      CssClass="dropdown" Width="180px">
                                      <asp:ListItem>Select Field Name</asp:ListItem>--%>
                                       <telerik:RadComboBox ID="ddlFielsName" runat="server" Skin="Vista" MarkFirstMatch="true" 
                                           AllowCustomText="true" EmptyMessage="Select Field Name">
                                       </telerik:RadComboBox>
                                 <%-- </asp:DropDownList>--%>
                                  </td>
                                  <td height="30px" align="left" class="heading">
                                      value :
                                      <asp:TextBox ID="txtValue" CssClass="inputBox7" runat="server"></asp:TextBox>
                                 </td>
                                   <td align="center">
                                   <asp:ImageButton ID="ImageButton2" runat="server" 
                                        ImageUrl="~/Images/refresh-btn.gif" onclick="ImageButton1_Click" />
                                  </td>
                            </tr>
                        </table>
                      </td>
                  </tr>
                  <tr><td valign="top">
    <script language="javascript" type ="text/javascript">
    changeBackground('AT');
</script>
  
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
                              <div style="width:750px;  border-top:1px solid #000; overflow:auto;"
                               <telerik:RadGrid ID="gviewAuditTrial" runat="server" AllowScroll="True" 
                                AllowSorting="True" GridLines="None" 
              
        AutoGenerateColumns="False" Skin="Office2007"   
                                                                 
                               EnableLinqExpressions="False"   
                                Font-Bold="False" Font-Italic="False" Font-Overline="False"  
                                 Font-Underline="False" 
                                AllowFilteringByColumn="True" 
                                 Width="747px" AllowPaging="True" 
                                    onpageindexchanged="gviewAuditTrial_PageIndexChanged" 
                                    onitemcommand="gviewAuditTrial_ItemCommand" 
                                    onneeddatasource="gviewAuditTrial_NeedDataSource"  
                               
                                
           <ExportSettings IgnorePaging="true" OpenInNewWindow="true">
</ExportSettings>
                   
<MasterTableView TableLayout="Fixed" Name="AuditMain" DataKeyNames="Auto_ID" Font-Bold="False" Font-Italic="False" Font-Overline="False" 
                                    Font-Strikeout="False" Font-Underline="False" AllowNaturalSort="False" 
                                    OverrideDataSourceControlSorting="True" HierarchyLoadMode="ServerOnDemand">
                                    <DetailTables >
                <telerik:GridTableView runat="server" DataKeyNames="T25_Auto_ID" Name="AuditDetail" HierarchyLoadMode="ServerOnDemand"  
                    AllowPaging="False" BackColor="#fffeee"
                      
                      
                                    <columns>
                                     <telerik:GridBoundColumn DataField="T25_Auto_ID"  HeaderText="T25_Auto_ID" Visible="false"   >
                <HeaderStyle Width="4px"/>
                           </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Field Name" HeaderText="Field Name"    ItemStyle-Wrap ="true"  >
                <HeaderStyle Width="225px"  Wrap = "true" />
                <ItemStyle Wrap="True" />
           </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Old Value" HeaderText="Old Value"  >
                <HeaderStyle Width="225px" />
           </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="New Value" HeaderText="New Value"   >
                <HeaderStyle Width="225px"   />
           </telerik:GridBoundColumn>
                                     </columns>
                                     </telerik:GridTableView>  
            </DetailTables>  
                                    <ExpandCollapseColumn Visible="True">
                                    </ExpandCollapseColumn>
            <Columns>
                                    <telerik:GridBoundColumn DataField="Auto_ID" HeaderText="Auto_ID" Visible="false"  >
                  
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="Form_Name" HeaderText="Form Name" FilterControlWidth="60px"
               <HeaderStyle Width="100px" />
                 
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="DB_Table_Name" HeaderText="DataBase Table Name" FilterControlWidth="100px"
                <HeaderStyle Width="140px" />
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="FName1" HeaderText="Created By" FilterControlWidth="70px">
                  <HeaderStyle Width="110px" />
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="FName" HeaderText="Modified By" FilterControlWidth="70px">
                  <HeaderStyle Width="110px" />
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="TableAffected_PK" HeaderText="Table Primary Key" FilterControlWidth="20px">
                 <HeaderStyle Width="60px" />
           </telerik:GridBoundColumn>
           
                             
                               <telerik:GridDateTimeColumn FilterControlWidth="120px" DataField="DateTime" HeaderText="Transaction DateTime" SortExpression="DateTime"
                        UniqueName="DateTime" PickerType="DatePicker">
                        <HeaderStyle Width="150px" />
                    </telerik:GridDateTimeColumn>
  
           <telerik:GridBoundColumn DataField="Type_of_Operation" HeaderText="Type of Operation" FilterControlWidth="40px">
           <HeaderStyle Width="75px" />
            </telerik:GridBoundColumn>
              
               
                 
              
  
                                   </Columns>
                                   </MasterTableView>
                                   <ClientSettings EnableRowHoverStyle="true" >
                <Selecting AllowRowSelect="true" />
                 <Resizing EnableRealTimeResize ="true" AllowColumnResize="True" ClipCellContentOnResize="false" ResizeGridOnColumnResize="true" />
                  
            </ClientSettings>
                                   </telerik:RadGrid>
                                   </div>
                                    </ContentTemplate>
                                     </asp:UpdatePanel></td></tr><tr><td height="5"></td></tr></table></td></tr><tr><td height="5"></td></tr></table>
</asp:Content>
<asp:Content ID="Content3" runat="server" contentplaceholderid="head">
  
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            color: Navy;
            outline-width: medium;
            outline-style: none;
            outline-color: invert;
            font-style: normal;
            font-variant: normal;
            font-weight: bold;
            font-size: 20px;
            line-height: 30px;
            font-family: Arial, Helvetica, sans-serif;
            height: 12px;
            padding-left: 3px;
        }
        .style3
        {
            height: 12px;
        }
    </style>
  
</asp:Content>
using System.Configuration;
using Telerik.Web.UI;
using System.Data.SqlClient;
  
public partial class AuditTrial : System.Web.UI.Page
{
    STSMessages ObjMessages = new STSMessages();
    STSDAL.Tracker ObjTracker = new STSDAL.Tracker(ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString);
    //STSDAL.FormFT ObjFormFT = new STSDAL.FormFT(ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString);
    private const string ASCENDING = " ASC";
    private const string DESCENDING = " DESC";
    DataSet DS = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session["Refresh"] = "";
            Session["combocount"] = 0;
            Session["Searchresult"] = "";
            FillAllAuditSearchcriteria();
            fillAllAuditTrialdetails();
             
            GridSortExpression sortExpr = new GridSortExpression();
            sortExpr.SortOrder = GridSortOrder.Ascending;
            gviewAuditTrial.MasterTableView.SortExpressions.AddSortExpression(sortExpr);
        }
          
    }
    private void fillAllAuditTrialdetails()
    {
        try
        {
            DataTable dtAllvalues = new DataTable();
            //if (Session["Combocount"] != null)
            //{
                if (Convert.ToInt16(Session["combocount"]) == 0)//(ddlInstituteNumber.Text.Trim() == "Select Institute Number" && ddlInstituteNumber.Text.Trim() == string.Empty) || (ddlProtocol.Text.Trim() == "Select Protocol Number" && ddlProtocol.Text.Trim() == string.Empty) || (ddlStudyNumber.Text.Trim() == "Select Study Number" && ddlStudyNumber.Text.Trim() == string.Empty) || (ddlBCN.Text.Trim() == "Select Biopsy Control Number" && ddlBCN.Text.Trim() == string.Empty) || (ddlLabNumber.Text.Trim() == "Select Lab Name" && ddlLabNumber.Text.Trim() == string.Empty) || (ddlSpecimenNumber.Text.Trim() == "Select Specimen Number" && ddlSpecimenNumber.Text.Trim() == string.Empty) || (ddlSpecimenCondition.Text.Trim() == "Select Specimen Condition" && ddlSpecimenCondition.Text.Trim() == string.Empty) || (ddlDisposalReason.Text.Trim() == "Select Disposal Status" && ddlDisposalReason.Text.Trim() == string.Empty) || (ddlBlockSubmissionType.Text.Trim() == "Select Submission Type" && ddlBlockSubmissionType.Text.Trim() == string.Empty) || (ddBlockType.Text.Trim() == "Select Block Type" && ddBlockType.Text.Trim() == string.Empty) || (ddlFielsName.Text.Trim() == "Select Field Name" && ddlFielsName.Text.Trim() == string.Empty) || (ddllabname.Text.Trim() == "Select Lab Number" && ddllabname.Text.Trim() == string.Empty))
                {
                    DS = ObjTracker.getAuditTrialmain();
                }
                else
                {
                    // DS=(DataSet)Session["Searchresult"];
                    fillSearchResult();
  
                }
            //}
        
        }
        catch (Exception ex)
        {
  
        }
          
    }
    private void FillAllAuditSearchcriteria()
    {
        try
        {
            DataSet dsSearch = new DataSet();
            dsSearch = ObjTracker.AuditSearchCriteria();
  
            RadComboBoxItem item11 = new RadComboBoxItem("Select Protocol Number", "0");
            if (dsSearch.Tables["T1_PROTOCOL_MAIN"].Rows.Count > 0 )
            {
            ddlProtocol.DataSource = dsSearch.Tables["T1_PROTOCOL_MAIN"];
            ddlProtocol.DataTextField="PROTOCOL_NUMBER";
            ddlProtocol.DataValueField = "PROTOCOL_ID";
            ddlProtocol.DataBind();
            ddlProtocol.SelectedIndex = -1;
            }
            ddlProtocol.Items.Insert(0,item11 );
  
            RadComboBoxItem item10 = new RadComboBoxItem("Select Institute Number", "0");
            if (dsSearch.Tables["T2_MEMBER_INSTITUTION"].Rows.Count > 0)
            {
                ddlInstituteNumber.DataSource = dsSearch.Tables["T2_MEMBER_INSTITUTION"];
                ddlInstituteNumber.DataTextField = "INST_ID";
                ddlInstituteNumber.DataValueField = "INST_ID";
                ddlInstituteNumber.DataBind();
                ddlInstituteNumber.SelectedIndex = -1;
            }
            ddlInstituteNumber.Items.Insert(0,item10 );
            RadComboBoxItem item2 = new RadComboBoxItem("Select Study Number", "0");
            if (dsSearch.Tables["T5_Patient_Eligibility"].Rows.Count > 0)
            {
                ddlStudyNumber.DataSource = dsSearch.Tables["T5_Patient_Eligibility"];
                ddlStudyNumber.DataTextField = "Study_Number";
                ddlStudyNumber.DataValueField = "Study_Number";
                ddlStudyNumber.DataBind();
                ddlStudyNumber.SelectedIndex = -1;
            }
            ddlStudyNumber.Items.Insert( 0,item2);
            RadComboBoxItem item3 = new RadComboBoxItem("Select Biopsy Control Number", "0");
            if (dsSearch.Tables["T4_Fresh_Tissue_Form"].Rows.Count > 0)
            {
                ddlBCN.DataSource = dsSearch.Tables["T4_Fresh_Tissue_Form"];
                ddlBCN.DataTextField = "Biopsy_Control_Number";
                ddlBCN.DataValueField = "Biopsy_Control_Number";
                ddlBCN.DataBind();
                ddlBCN.SelectedIndex = -1;
            }
            ddlBCN.Items.Insert(0, item3);
  
            RadComboBoxItem item9 = new RadComboBoxItem("Select Lab Name", "0");
            if (dsSearch.Tables["T7_External_Labs"].Rows.Count > 0)
            {
                ddlLabNumber.DataSource = dsSearch.Tables["T7_External_Labs"];
                ddlLabNumber.DataTextField = "Lab_Name";
                ddlLabNumber.DataValueField = "Lab_Number";
                ddlLabNumber.DataBind();
                ddlLabNumber.SelectedIndex = -1;
            }
            ddlLabNumber.Items.Insert(0, item9);
  
            RadComboBoxItem item8 = new RadComboBoxItem("Select Specimen Condition", "0");
            if (dsSearch.Tables["T15_Lab_Accession_Details"].Rows.Count > 0)
            {
                ddlSpecimenNumber.DataSource = dsSearch.Tables["T15_Lab_Accession_Details"];
                ddlSpecimenNumber.DataTextField = "Lab_Accession_Number";
                ddlSpecimenNumber.DataValueField = "Lab_Accession_Number";
                ddlSpecimenNumber.DataBind();
                ddlSpecimenNumber.SelectedIndex = -1;
            }
            ddlSpecimenNumber.Items.Insert(0, item8);
  
            RadComboBoxItem item7 = new RadComboBoxItem("Select Specimen Condition", "0");
            if (dsSearch.Tables["T11_Specimen_Status"].Rows.Count > 0)
            {
                ddlSpecimenCondition.DataSource = dsSearch.Tables["T11_Specimen_Status"];
                ddlSpecimenCondition.DataTextField = "Specimen_Status_Name";
                ddlSpecimenCondition.DataValueField = "ID";
                ddlSpecimenCondition.DataBind();
                ddlSpecimenCondition.SelectedIndex = -1;
            }
            ddlSpecimenCondition.Items.Insert(0,item7 );
  
            RadComboBoxItem item4 = new RadComboBoxItem("Select Disposal Status", "0");
            if (dsSearch.Tables["T14_Disposal_Status"].Rows.Count > 0)
            {
                ddlDisposalReason.DataSource = dsSearch.Tables["T14_Disposal_Status"];
                ddlDisposalReason.DataTextField = "Disposal_Status_Name";
                ddlDisposalReason.DataValueField = "ID";
                ddlDisposalReason.DataBind();
                ddlDisposalReason.SelectedIndex = -1;
            }
            ddlDisposalReason.Items.Insert(0,item4 );
  
            RadComboBoxItem item5 = new RadComboBoxItem("Select Submission Type", "0");
            if (dsSearch.Tables["T17_Block_Type"].Rows.Count > 0)
            {
                ddlBlockSubmissionType.DataSource = dsSearch.Tables["T17_Block_Type"];
                ddlBlockSubmissionType.DataTextField = "Block_Name";
                ddlBlockSubmissionType.DataValueField = "Block_Name";
                ddlBlockSubmissionType.DataBind();
                ddlBlockSubmissionType.SelectedIndex = -1;
            }
            ddlBlockSubmissionType.Items.Insert(0,item5 );
  
            RadComboBoxItem item6 = new RadComboBoxItem("Select Field Name", "0");
            if (dsSearch.Tables["Block Type"].Rows.Count > 0)
            {
                ddlFielsName.DataSource = dsSearch.Tables["Block Type"];
                ddlFielsName.DataTextField = "FieldName";
                ddlFielsName.DataValueField = "FieldName";
                ddlFielsName.DataBind();
                ddlFielsName.SelectedIndex = -1;
            }
            ddlFielsName.Items.Insert(0, item6);
  
            RadComboBoxItem item1 = new RadComboBoxItem("Select Lab Number", "0");
            if (dsSearch.Tables["Labname"].Rows.Count > 0)
            {
                ddllabname.DataSource = dsSearch.Tables["Labname"];
                ddllabname.DataTextField = "Lab number";
                ddllabname.DataValueField = "Specimen_Number";
                ddllabname.DataBind();
                ddllabname.SelectedIndex = -1;
            }
            ddllabname.Items.Insert(0,item1);
        }
        catch (Exception ex)
        {
        }
    }
  
    protected void gviewAuditTrial_PageIndexChanged(object source, GridPageChangedEventArgs e)
    {
        try
        {
  
            gviewAuditTrial.CurrentPageIndex = e.NewPageIndex;
            if (Session["Refresh"] == "")
            {
                fillAllAuditTrialdetails();
            }
            else if (Session["Refresh"] == "Filter")
            {
                 fillSearchResult();
            }
        }
        catch (Exception ex)
        {
  
        }
    }
    protected void gviewAuditTrial_ItemCommand(object source, GridCommandEventArgs e)
    {
        //if ((ddlInstituteNumber.Text.Trim() == "Select Institute Number" && ddlInstituteNumber.Text.Trim() == string.Empty) || (ddlProtocol.Text.Trim() == "Select Protocol Number" && ddlProtocol.Text.Trim() == string.Empty) || (ddlStudyNumber.Text.Trim() == "Select Study Number" && ddlStudyNumber.Text.Trim() == string.Empty) || (ddlBCN.Text.Trim() == "Select Biopsy Control Number" && ddlBCN.Text.Trim() == string.Empty) || (ddlLabNumber.Text.Trim() == "Select Lab Name" && ddlLabNumber.Text.Trim() == string.Empty) || (ddlSpecimenNumber.Text.Trim() == "Select Specimen Number" && ddlSpecimenNumber.Text.Trim() == string.Empty) || (ddlSpecimenCondition.Text.Trim() == "Select Specimen Condition" && ddlSpecimenCondition.Text.Trim() == string.Empty) || (ddlDisposalReason.Text.Trim() == "Select Disposal Status" && ddlDisposalReason.Text.Trim() == string.Empty) || (ddlBlockSubmissionType.Text.Trim() == "Select Submission Type" && ddlBlockSubmissionType.Text.Trim() == string.Empty) || (ddBlockType.Text.Trim() == "Select Block Type" && ddBlockType.Text.Trim() == string.Empty) || (ddlFielsName.Text.Trim() == "Select Field Name" && ddlFielsName.Text.Trim() == string.Empty) || (ddllabname.Text.Trim() == "Select Lab Number" && ddllabname.Text.Trim() == string.Empty))
        //{
        //if (e.CommandName == "Filter")
        //{
           // gviewAuditTrial.DataSource = null;
            fillAllAuditTrialdetails();
        //}
             
        ////}
        //else
        //{
        //    fillSearchResult();
        //}
    }
    protected void gviewAuditTrial_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)
    {
        GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
        GridDataItem parentItem = e.DetailTableView.ParentItem as GridDataItem;
  
        switch (e.DetailTableView.Name)
        {
            case "AuditDetail":
                {
                    string Auto_ID = dataItem.GetDataKeyValue("Auto_ID").ToString();
                    e.DetailTableView.DataSource = DS.Tables["AuditDetail"].Select("T25_Auto_ID = '" + parentItem["Auto_ID"].Text + "'");
                     
                    //e.DetailTableView.Columns[1].HeaderStyle.Width = 50;
                    //e.DetailTableView.ItemStyle.BorderStyle=
                    e.DetailTableView.AllowFilteringByColumn = false;
                    e.DetailTableView.AllowSorting = false;
                }
                break;
        }
  
  
  
  
    }
    protected void gviewAuditTrial_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        if (!e.IsFromDetailTable)
        {
            if (Convert.ToInt16(Session["combocount"]) != 0)
            {
                DS= (DataSet) (Session["Searchresult"]);
                gviewAuditTrial.DataSource = DS.Tables["AuditMain"];
               // Session["Searchresult"] = DS;
            }
            else
            {
                gviewAuditTrial.DataSource = DS.Tables["AuditMain"];
            }
  
        }
        gviewAuditTrial.DetailTableDataBind += new GridDetailTableDataBindEventHandler(gviewAuditTrial_DetailTableDataBind);
         
  
    }
    protected void btnRefresh_Click(object sender, EventArgs e)
    {
        fillSearchResult();
    }
    public void ShowErrorMessage(string message)
    {
        RegisterStartupScript("men", "<script languaje=javascript'> alert('" + message + "'); </script>");
    }
    private void NoRecords()
    {
        DataTable dtempty = new DataTable();
        try
        {
            dtempty.Columns.Add("FormName");
            dtempty.Columns.Add("Database TableName");
            dtempty.Columns.Add("Created By");
            dtempty.Columns.Add("Modified By");
            dtempty.Columns.Add("Transaction DateTime");
            gviewAuditTrial.DataSource = dtempty;
            gviewAuditTrial.DataBind();
            gviewAuditTrial.AllowFilteringByColumn = false;
        }
        catch (Exception ex)
        {
        }
  
    }
  
    private void fillSearchResult()
    {
        try
        {
            //code change
            gviewAuditTrial.CurrentPageIndex = 0;
            //
            int combocount = 0;
            string strquery = " ";
            Session["Refresh"] = "Filter";
            if (ddlProtocol.Text.Trim() != "Select Protocol Number" && ddlProtocol.Text.Trim() != string.Empty)
            {
                strquery += " or (FieldName='Protocol_ID' and (T26.OldValue= '" + ddlProtocol.SelectedItem.Text + "' or T26.NewValue= '" + ddlProtocol.SelectedItem.Text + "' ))";
                combocount += 1;
                  
            }
            if (ddlInstituteNumber.Text.Trim() != "Select Institute Number" && ddlInstituteNumber.Text.Trim() != string.Empty)
            {
                strquery += " or (FieldName='Institution_Number' and (T26.OldValue= '" + ddlInstituteNumber.Text.Trim() + "' or T26.NewValue= '" + ddlInstituteNumber.Text.Trim() + "' ))";
                combocount += 1;
                  
            }
            if (ddlStudyNumber.Text.Trim() != "Select Study Number" && ddlStudyNumber.Text.Trim() != string.Empty)
            {
                strquery += " or (FieldName='Study_Number' and (T26.OldValue= '" + ddlStudyNumber.Text.Trim() + "' or T26.NewValue= '" + ddlStudyNumber.Text.Trim() + "' ))";
                combocount += 1;
                  
            }
            if (ddlBCN.Text.Trim() != "Select Biopsy Control Number" && ddlBCN.Text.Trim() != string.Empty)
            {
                strquery += " or (FieldName='T4_Biopsy_Control_Number' and (T26.OldValue= '" + ddlBCN.Text.Trim() + "' or T26.NewValue= '" + ddlBCN.Text.Trim() + "' ))";
                combocount += 1;
                  
            }
            if (ddlLabNumber.Text.Trim() != "Select Lab Name" && ddlLabNumber.Text.Trim() != string.Empty)
            {
                strquery += " or (FieldName='T7_External_Lab_ID' and (T26.OldValue= '" + ddlLabNumber.SelectedItem.Text + "' or T26.NewValue= '" + ddlLabNumber.SelectedItem.Text + "' ))";
                combocount += 1;
                  
            }
            if (ddlSpecimenNumber.Text.Trim() != "Select Specimen Number" && ddlSpecimenNumber.Text.Trim() != string.Empty)
            {
                 
                strquery += " or (FieldName='Lab_Accession_Number' and (T26.OldValue= '" + ddlSpecimenNumber.Text.Trim() + "' or T26.NewValue= '" + ddlSpecimenNumber.Text.Trim() + "' ))";
                combocount += 1;
            }
             
            if (ddlSpecimenCondition.Text.Trim() != "Select Specimen Condition" && ddlSpecimenCondition.Text.Trim() != string.Empty)
            {
                strquery += " or (FieldName='Specimen_Condition' and (T26.OldValue= '" + ddlSpecimenCondition.SelectedItem.Text.Trim() + "' or T26.NewValue= '" + ddlSpecimenCondition.SelectedItem.Text.Trim() + "' ))";
                combocount += 1;
                  
            }
            if (ddlDisposalReason.Text.Trim() != "Select Disposal Status" && ddlDisposalReason.Text.Trim() != string.Empty)
            {
                strquery += " or (FieldName='Disposal_Reason' and (T26.OldValue= '" + ddlDisposalReason.SelectedItem.Text.Trim() + "' or T26.NewValue= '" + ddlDisposalReason.SelectedItem.Text.Trim() + "' ))";
                combocount += 1;
                 
            }
            if (ddlBlockSubmissionType.Text.Trim() != "Select Submission Type" && ddlBlockSubmissionType.Text.Trim() != string.Empty)
            {
                strquery += " or (FieldName='Submission_Type' and (T26.OldValue= '" + ddlBlockSubmissionType.SelectedItem.Text.Trim() + "' or T26.NewValue= '" + ddlBlockSubmissionType.SelectedItem.Text.Trim() + "' ))";
                combocount += 1;
                 
            }
  
            if (ddBlockType.Text.Trim() != "Select Block Type" && ddBlockType.Text.Trim() != string.Empty)
            {
                strquery +=  "or  (FieldName='Specimen_Node_Type' and (T26.OldValue= '" + ddBlockType.SelectedValue.ToString().Trim() + "' or T26.NewValue= '" + ddBlockType.SelectedValue.ToString().Trim() + "' ))";
                combocount += 1;
  
            }
            if (ddlFielsName.Text.Trim() != "Select Field Name" && ddlFielsName.Text.Trim() != string.Empty)
            {
                strquery += " or (FieldName='" + ddlFielsName.SelectedItem.Text.ToString() + "' and (T26.OldValue= '" + txtValue.Text.ToString().Trim() + "' or T26.NewValue= '" + txtValue.Text.ToString().Trim() + "' ))";
                combocount += 1;
  
            }
            if (ddllabname.Text.Trim() != "Select Lab Number" && ddllabname.Text.Trim() != string.Empty)
            {
                strquery += " or (FieldName='Lab_Number' and (T26.OldValue= '" + ddllabname.SelectedValue.ToString() + "' or T26.NewValue= '" + ddllabname.SelectedValue.ToString() + "' ))";
                strquery += " or (FieldName='Specimen_Number' and (T26.OldValue= '" + ddllabname.SelectedValue.ToString() + "' or T26.NewValue= '" + ddllabname.SelectedValue.ToString() + "' ))";
                combocount += 1;
  
            }
  
            if (combocount == 0)
            {
               ShowErrorMessage("Please Select any Search Criteria");
              // Session["combocount"] = 0;
               fillAllAuditTrialdetails();
              // gviewAuditTrial.DataSource = DS.Tables["AuditMain"];
               //gviewAuditTrial.DataBind();
                return;
            }
            string strcut = strquery.Remove(0, 4);
            DataSet DsSearch = new DataSet();
            DS = ObjTracker.getSearchResult(strcut, combocount);
            if (DS.Tables.Count >= 2)
            {
                if (DS.Tables["AuditMain"].Rows.Count >= 1)
                {
                      
                    Session["combocount"] = combocount;
                    Session["Searchresult"] = DS;
                        gviewAuditTrial.DataSource = DS.Tables["AuditMain"];
                        gviewAuditTrial.Rebind();
                    //}
                    //gviewAuditTrial.DetailTableDataBind += new GridDetailTableDataBindEventHandler(gviewAuditTrial_DetailTableDataBind);
                }
  
                else
                {
                    NoRecords();
                }
            }
            else
            {
                NoRecords();
            }
            //
            //foreach (GridColumn column in gviewTasks.MasterTableView.Columns)
            //{
            //    column.CurrentFilterFunction = GridKnownFunction.NoFilter;
            //    column.CurrentFilterValue = string.Empty;
            //}
            //gviewTasks.MasterTableView.FilterExpression = string.Empty;
            //gviewTasks.MasterTableView.Rebind();
            //
            //foreach (GridColumn column in gviewAuditTrial.MasterTableView.Columns)
            //{
            //column.CurrentFilterFunction = GridKnownFunction.NoFilter;
            //column.CurrentFilterValue = string.Empty;
            //}
            //gviewAuditTrial.MasterTableView.FilterExpression = string.Empty;
            //gviewAuditTrial.MasterTableView.Rebind();
        }
        catch (Exception ex)
        {
  
        }
    }
  
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        fillSearchResult();
    }
}

3 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 15 Feb 2012, 09:58 AM
Hello,

Can you confirm that on doing the external search both NeedDataSource and DetailTableDataBind get fired? I see some parts of your code lead to a call of DataBind() for RadGrid which is expected to build the hierarchical functionality.

Greetings,
Tsvetina
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Prasad
Top achievements
Rank 1
answered on 16 Feb 2012, 06:13 AM
Thanks for the reply.

We are not using DataBind()  in the external search, we are using Rebind() method over here. when we call Rebind() method it is going to NeedDatasource event and registering DetailTableDataBind successfully but when we elaborate  parent row it is not showing values (child rows) and observed values are getting binded in the data source but when we are expanding the parent row we could not see child rows.

For your reference code was attached in the previous post.
0
Tsvetina
Telerik team
answered on 20 Feb 2012, 02:17 PM
Hello,

We looked through your code but we could not see anything else that would be an obvious mistake. The only other thing that comes to my mind is if you have any ajax settings for the grid - in such scenario you should also have one where the grid is updated by the control that triggers the search.
If this is not the issue would it be possible that you open a ticket and send us a sample project demonstrating the issue at hand?

All the best,
Tsvetina
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Grid
Asked by
Prasad
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Prasad
Top achievements
Rank 1
Share this question
or