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

Grid Disappears After Filter Set or Column Sorted

3 Answers 706 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lynn
Top achievements
Rank 2
Lynn asked on 18 Nov 2011, 05:24 PM
I'm sure the problem I'm having is something I am doing, but I have no idea what it might be.  Here's the situation...

I have a web page (.aspx/.aspx.cs) that is essentially a "master/detail" display.  The "master" record fields are displayed as labels and the "detail" records are displayed in a grid using a SQLDataSource with a Select Command that is set at run time depending upon the key value of the "master" record.

I have followed one of your grid examples in trying to set this page up, however I did not find one of your examples that uses filters/sorting on the grid and also contains the "master" data fields displayed above.

Here's what happens:
(a) When the page is first displayed everything is fine.  The "master" fields are populated corretly and the grid is populated correctly (although I have some minor display issues currently).  A screen capture of the resulting page is attached as "Picture 1".

(b) When I enter a filter (doesn't matter which column or what type of filter), the page is re-displayed and the grid is totally gone from the page. A screen capture of the resulting page is attached as "Picture 2".

(c) I have taken all of the grid-related code out of the .aspx and put in another page without the "master" data, applied a filter, and it works just fine.  A screen capture of the resulting page is attached as "Picture 3".  

Obviously the problem has something to do with the display of the "master" data.  But I just have no idea what it might be.  The code for the .aspx file only for the "Grid Only" page (used to produce "Picture 3") is attached next.  There is no code in the code behind page.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Z_GridTest.aspx.cs" Inherits="Z_GridTest" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
 
      <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <!-- content start -->
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="SignersGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="SignersGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
 
    <div>
     
                        <telerik:RadGrid AutoGenerateColumns="false" ID="SignersGrid" runat="server" Width="99.7%"
                            AllowSorting="true" AllowFilteringByColumn="true" EnableLinqExpressions="false"
                            AllowPaging="false" PageSize="15"
                            BorderWidth="1px" BorderColor="#999999" EnableEmbeddedSkins="true" Skin="Default"
                            DataSourceID="SQLDataSource1"
                            ShowFooter="True" GridLines="None" >
                            <PagerStyle Mode="NextPrevAndNumeric" />
                            <GroupingSettings CaseSensitive="false" />
                            <MasterTableView AutoGenerateColumns="false" EditMode="InPlace" AllowFilteringByColumn="True"
                                ShowFooter="True" TableLayout="Auto">
                                <Columns>
 
                                    <telerik:GridBoundColumn FilterControlWidth="50px" HeaderText="FirstName" UniqueName="FirstName"
                                        DataField="FirstName" SortExpression="FirstName" >
                                    </telerik:GridBoundColumn>
 
                                    <telerik:GridBoundColumn UniqueName="LastName" Visible="true" DataField="LastName" SortExpression="LastName" >
                                    </telerik:GridBoundColumn>
 
                                    <telerik:GridBoundColumn UniqueName="VoterAddress" HeaderText="Address" DataField="Address" SortExpression="Address"  >
                                    </telerik:GridBoundColumn >
 
                                    <telerik:GridBoundColumn UniqueName="RemoveSignature" HeaderText="Remove" DataField="CountyId" >
                                    </telerik:GridBoundColumn>
                                     
                                    <telerik:GridBoundColumn UniqueName="MiddleName" Visible="false" DataField="MiddleName" >
                                    </telerik:GridBoundColumn>
 
                                    <telerik:GridBoundColumn UniqueName="NameSuffix" Visible="false" DataField="NameSuffix" >
                                    </telerik:GridBoundColumn>
 
                                </Columns>
                            </MasterTableView>
                            <ClientSettings>
                                <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                            </ClientSettings>
                        </telerik:RadGrid>
 
    <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:ElectronicPetitionSystemConnectionString %>"
    SelectCommand="SELECT VoterSignatureId, PetitionId, LastName, FirstName, MiddleName, NameSuffix, [Address], CountyId, Email, SignatureImage, CountyVoterId, MvdSerialNumber, DateSigned, ClientIpAddress, VoterSignatureStatusId, CreatedDate, ModifiedDate FROM VoterSignatures WHERE PetitionId = 1001"
    ProviderName="System.Data.SqlClient" runat="server">
    </asp:SqlDataSource>
 
    </div>
    </form>
</body>
</html>

The code below is the "full version" including the display of the "master" fields.  This page does contain one statement in the Page_Init  event (not a postback only) which sets the value of the Select Command based on the value of a request qeury string member.

<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/EPSDev3.master" AutoEventWireup="true" CodeFile="PetitionInfo.aspx.cs" Inherits="PetitionInfo" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
    .VerticalAlign1 
    
        padding-top: 6px;
    }
</style>
 </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 
      <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
        <!-- content start -->
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="SignersGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="SignersGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
 
 
 
    <div style="width: 800px;">
        <div style="float: left; background-color: White; width: 100%; padding: 0px;">
            <table cellpadding="1" cellspacing="0" border="0" width="100%">
                <tr>
                    <td colspan="5" align="center" >
                        <h2>
                            <asp:Label ID="VoterAuthenticationLabel" runat="server" Text="<%$ Resources:Resource, PetitionInformationLabel %>"></asp:Label>
                        </h2>
                    </td>
                </tr>
                <tr>
                    <td width="2%">
                          
                    </td>
                    <td width="47%" valign="top">
                        <table width="100%">
                            <tr>
                                <td colspan="2" align="left" style="font-weight: normal; height: 12px;">
                                    <asp:Label ID="Label6" runat="server" Font-Bold="true" Text="<%$ Resources:Resource, CandidateInformationLabel%>"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <asp:Label ID="CycleLabel" runat="server" Text="<%$ Resources:Resource, CycleLabel %>"></asp:Label>
                                </td>
                                <td align="left">
                                    <asp:Label ID="ElectionCycleList" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <asp:Label ID="Label1" runat="server" Text="<%$ Resources:Resource, RaceLabel %>"></asp:Label>
                                </td>
                                <td align="left">
                                    <asp:Label ID="PoliticalRaceList" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <asp:Label ID="Label2" runat="server" Text="<%$ Resources:Resource, NameLabel %>"></asp:Label>
                                </td>
                                <td align="left">
                                    <asp:Label ID="CandidateName" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <asp:Label ID="Label3" runat="server" Text="<%$ Resources:Resource, AddressLabel %>"></asp:Label>
                                </td>
                                <td align="left">
                                    <asp:Label ID="CandidateAddress" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <asp:Label ID="Label4" runat="server" Text="<%$ Resources:Resource, CityStZipLabel %>"></asp:Label>
                                </td>
                                <td align="left">
                                    <asp:Label ID="CandidateCity" runat="server" Text=""></asp:Label>
                                       
                                    <asp:Label ID="CandidateState" runat="server" Text=""></asp:Label>
                                       
                                    <asp:Label ID="CandidateZipCode" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <asp:Label ID="Label5" runat="server" Text="<%$ Resources:Resource, CountyLabel %>"></asp:Label>
                                </td>
                                <td align="left">
                                    <asp:Label ID="CandidateCountyList" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td width="2%">
                          
                    </td>
                    <td width="47%"  valign="top">
                        <table width="100%">
                            <tr>
                                <td colspan="2" align="left" style="font-weight: normal; height: 12px;">
                                    <asp:Label ID="Label7" runat="server" Font-Bold="true" Text="<%$ Resources:Resource, ContactInformationLabel%>"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <asp:Label ID="Label8" runat="server" Text="<%$ Resources:Resource, NameLabel %>"></asp:Label>
                                </td>
                                <td align="left">
                                    <asp:Label ID="ContactName" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <asp:Label ID="Label9" runat="server" Text="<%$ Resources:Resource, PhoneLabel %>"></asp:Label>
                                </td>
                                <td align="left">
                                    <asp:Label ID="ContactPhone" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <asp:Label ID="Label10" runat="server" Text="<%$ Resources:Resource, EmailLabel %>"></asp:Label>
                                </td>
                                <td align="left">
                                    <asp:Label ID="ContactEmailAddress" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <asp:Label ID="Label11" runat="server" Text="<%$ Resources:Resource, WebSiteLabel %>"></asp:Label>
                                </td>
                                <td align="left">
                                    <asp:Label ID="ContactWebSiteURL" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td align="left">
                                    <asp:Label ID="Label16" runat="server" Text="<%$ Resources:Resource, LinkToLabel %>"></asp:Label>
                                </td>
                                <td align="left">
                                    <asp:Label ID="LinkToURL" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td width="2%">
                          
                    </td>
                </tr>
                <tr>
                    <td colspan="5">
                          
                    </td>
                </tr>
                <tr >
                    <td>
                          
                    </td>
                        <td align="center" valign="middle" colspan="3" >
                            <asp:Label CssClass="VerticalAlign1" ID="PetitionsListTitle" Font-Size="16px" Width="100%" BackColor="#565A43" Height="24px" ForeColor="#ffffff" Font-Bold="true" runat="server" Text="<%$ Resources:Resource, PetitionSignersLabel %>"></asp:Label>
                        </td>
                    <td>
                          
                    </td>
                </tr>
                <tr>
                    <td width="2%">
                          
                    </td>
                    <td colspan="3" valign="middle">
                        <telerik:RadGrid AutoGenerateColumns="false" ID="SignersGrid" runat="server" Width="99.7%"
                            AllowSorting="true" AllowFilteringByColumn="true" EnableLinqExpressions="false"
                            AllowPaging="false" PageSize="15"
                            BorderWidth="1px" BorderColor="#999999" EnableEmbeddedSkins="true" Skin="Default"
                            DataSourceID="SQLDataSource1"
                            ShowFooter="True" GridLines="None" >
                            <PagerStyle Mode="NextPrevAndNumeric" />
                            <GroupingSettings CaseSensitive="false" />
                            <MasterTableView AutoGenerateColumns="false" EditMode="InPlace" AllowFilteringByColumn="True"
                                ShowFooter="True" TableLayout="Auto">
                                <Columns>
 
                                    <telerik:GridBoundColumn FilterControlWidth="50px" HeaderText="FirstName" UniqueName="FirstName"
                                        DataField="FirstName" SortExpression="FirstName" >
                                    </telerik:GridBoundColumn>
 
                                    <telerik:GridBoundColumn UniqueName="LastName" Visible="true" DataField="LastName" SortExpression="LastName" >
                                    </telerik:GridBoundColumn>
 
                                    <telerik:GridBoundColumn UniqueName="VoterAddress" HeaderText="Address" DataField="Address" SortExpression="Address"  >
                                    </telerik:GridBoundColumn >
 
                                    <telerik:GridBoundColumn UniqueName="RemoveSignature" HeaderText="Remove" DataField="CountyId" >
                                    </telerik:GridBoundColumn>
                                     
                                    <telerik:GridBoundColumn UniqueName="MiddleName" Visible="false" DataField="MiddleName" >
                                    </telerik:GridBoundColumn>
 
                                    <telerik:GridBoundColumn UniqueName="NameSuffix" Visible="false" DataField="NameSuffix" >
                                    </telerik:GridBoundColumn>
 
                                </Columns>
                            </MasterTableView>
                            <ClientSettings>
                                <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                            </ClientSettings>
                        </telerik:RadGrid>
                    </td>
                    <td width="2%">
                          
                    </td>
                </tr>
 
                <tr>
                    <td colspan="5" align="center" >
                        <asp:Label ID="Label17" runat="server" Text=""></asp:Label>
                    </td>
                </tr>
 
                <tr>
                    <td colspan="5" align="center" >
                        <asp:Label ID="SignatureCountMessage" runat="server" Text=""></asp:Label>
                    </td>
                </tr>
 
                <tr>
                    <td colspan="5" align="center" >
                        <asp:Label ID="Label18" runat="server" Text=""></asp:Label>
                    </td>
                </tr>
 
                <tr>
                    <td colspan="5" align="center" >
                          
                    </td>
                </tr>
 
                <tr>
                    <td colspan="5" align="center" >
                          
                    </td>
                </tr>
                <tr>
                    <td colspan="5" align="center" >
                          
                    </td>
                </tr>
 
 
 
                <tr >
                    <td>
                          
                    </td>
                        <td align="center" valign="middle" colspan="3" >
                            <asp:Label CssClass="VerticalAlign1" ID="Label12" Font-Size="16px" Width="100%" BackColor="#565A43" Height="24px" ForeColor="#ffffff" Font-Bold="true" runat="server" Text="<%$ Resources:Resource, SearchPetitionSignersLabel %>"></asp:Label>
                        </td>
                    <td>
                          
                    </td>
                </tr>
                <tr>
                    <td colspan="5" align="center" >
                          
                    </td>
                </tr>
                <tr>
                    <td width="2%">
                          
                    </td>
                    <td width="47%" valign="top">
                        <table width="100%">
                            <tr>
                                <td align="left">
                                    <asp:Label ID="Label15" runat="server" Text="<%$ Resources:Resource, FirstLastNameLabel %>"></asp:Label>
                                </td>
                                <td align="left">
                                    <asp:TextBox ID="SearchFirstName" Width="80px" runat="server" TabIndex="1"></asp:TextBox>
                                       
                                    <asp:TextBox ID="SearchLastName" Width="80px" runat="server" TabIndex="2"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td width="2%">
                          
                    </td>
                    <td width="47%"  valign="top">
                        <table width="100%">
                            <tr>
                                <td align="left">
                                    <asp:Label ID="Label13" runat="server" Text="<%$ Resources:Resource, AddressLabel %>"></asp:Label>
                                </td>
                                <td align="left">
                                    <asp:TextBox ID="SearchAddress" runat="server" TabIndex="3"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td width="2%">
                          
                    </td>
                </tr>
 
                <tr>
                    <td colspan="5" align="center" >
                        <asp:RadioButtonList ID="TypeOfCompare" runat="server" CellSpacing="10" RepeatDirection="Horizontal" >
                            <asp:ListItem Enabled="True" Selected="True" Text="Contains the value anywhere" Value="1" />
                            <asp:ListItem Enabled="True" Selected="False" Text="Only check the beginning of the entry" Value="2" />
                        </asp:RadioButtonList>
                         
                        <br />
                        <asp:Label ID="SearchInstructions" runat="server" Text="<%$ Resources:Resource, SearchInstructionsLabel %>"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td colspan="5" align="center" >
                          
                    </td>
                </tr>
                <tr>
                    <td colspan="5" align="center" >
                          
                    </td>
                </tr>
                <tr >
                    <td>
                          
                    </td>
                        <td align="center" valign="middle" colspan="3" >
                            <asp:Label CssClass="VerticalAlign1" ID="Label14" Font-Size="16px" Width="100%" BackColor="#565A43" Height="24px" ForeColor="#ffffff" Font-Bold="true" runat="server" Text="<%$ Resources:Resource, CloseAndPrintLabel %>"></asp:Label>
                        </td>
                    <td>
                          
                    </td>
                </tr>
                <tr>
                    <td colspan="5" align="center" >
                          
                    </td>
                </tr>
                <tr>
                    <td colspan="5" align="center" >
                        <asp:Button ID="ClosePetitionButton" TabIndex="6" runat="server" Text="<%$ Resources:Resource, ClosePetitionBtn %>" />
                            
                        <asp:Button ID="PrintListButton" TabIndex="7" runat="server" Text="<%$ Resources:Resource, PrintListBtn %>" />
                            
                        <asp:Button ID="PrintForFilingButton" TabIndex="8" runat="server" Text="<%$ Resources:Resource, PrintForFilingBtn %>" />
                    </td>
                </tr>
                <tr>
                    <td colspan="5" align="center" >
                          
                    </td>
                </tr>
            </table>
        </div>
        <div class="clear">
        </div>
    </div>
    <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:ElectronicPetitionSystemConnectionString %>"
        ProviderName="System.Data.SqlClient" runat="server">
    </asp:SqlDataSource>
 
 
</asp:Content>

Can anyone tell me why the display of the "master" data messes with the display/re-display of the grid on the page?

Many thanks in advance for your efforts!

Lynn






3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 18 Nov 2011, 06:31 PM
Hello,

EnableLinqExpressions="true"

Thanks,
Jayesh Goyani
0
Lynn
Top achievements
Rank 2
answered on 23 Nov 2011, 12:15 AM
Jayesh,

Thanks for your contribution, but that has not corrected the issue.  The entire grid still disappears when a filter is applied or a column is sorted.
Lynn
0
Lynn
Top achievements
Rank 2
answered on 23 Nov 2011, 07:04 PM
I resolved this a few minutes ago...the problem was that the SqlDataSource SelectCommand was not being correctly set on postbacks.  As a result, the grid would be populated correctly at page load, but each change after that (i.e. - sorting on different columns, applying filters, etc.) the grid would come back unpopulated.
Tags
Grid
Asked by
Lynn
Top achievements
Rank 2
Answers by
Jayesh Goyani
Top achievements
Rank 2
Lynn
Top achievements
Rank 2
Share this question
or