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

How to Hide a Panel if after Filtering, RadGrid Rowcount = 0

2 Answers 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
gc_0620
Top achievements
Rank 1
gc_0620 asked on 28 Aug 2012, 07:42 PM

Folks, Using RadControls for ASP.NET AJAX Q2 2012 SP1 with VS 2010.

My Radgrid has approximately 65000 rows; uses LinqDataSource. also I have a external Panel (Panelotherinfo) to Navigate to other forms.

I would like to make that Panel:
 - Invisible if after Filtering RadGrid has no rows.
-  Visible if after Filtering Radgrid has rows.

Below is my Radgrid and panel declaration as well as RadGrid1_ItemEvent.

Thanks for any help

gc_0620

_______________

<telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" Width="99.9%"
            Font-Size="11px" AllowPaging="True" AllowSorting="True" CellSpacing="0" GridLines="None"
            Skin="Office2007" PagerStyle-Mode="NextPrevNumericAndAdvanced" OnPreRender="RadGrid1_PreRender"
            OnUpdateCommand="RadGrid1_UpdateCommand" DataSourceID="LinqDataSourceClient"
            OnItemDataBound="RadGrid1_ItemDataBound"
            OnItemCommand="RadGrid1_ItemCommand" onitemcreated="RadGrid1_ItemCreated"
           onitemevent="RadGrid1_ItemEvent">
           ''''
           ''''
  
</telerik:RadGrid>
 
 
<asp:Panel ID="Panelotherinfo" runat="server">
        <h3 style="background-color: #9fba2d; color: White; width: 20%; margin-left: 5px">
            Client other information</h3>
        <br />
        <telerik:RadSiteMap ID="RadSiteMap1" runat="server" Skin="Sitefinity" Width="50%">
            <Nodes>
                <telerik:RadSiteMapNode runat="server" Text="Contact/Race/PrimarryLanguage and Ethnicity/Anchestry"
                    NavigateUrl="~/Default.aspx">
                </telerik:RadSiteMapNode>
                <telerik:RadSiteMapNode runat="server" Text="Demographic/HouseholdComposition/Monthly Income"
                    NavigateUrl="~/NotReadyyet.aspx">
                </telerik:RadSiteMapNode>
                <telerik:RadSiteMapNode runat="server" Text="Encounter">
                </telerik:RadSiteMapNode>
            </Nodes>
            <LevelSettings>
                <telerik:SiteMapLevelSetting Layout="Flow">
                    <ListLayout AlignRows="True" RepeatColumns="3" />
                </telerik:SiteMapLevelSetting>
            </LevelSettings>
        </telerik:RadSiteMap>
    </asp:Panel>
 
 
 
 
  protected void RadGrid1_ItemEvent(object sender, GridItemEventArgs e)
    {
        int rowcount = 0;
 
        if (e.EventInfo is GridInitializePagerItem)
        {
            rowcount = (e.EventInfo as GridInitializePagerItem).PagingManager.DataSourceCount;
        }
 
        if (rowcount == 0)
 
            Panelotherinfo.Visible = false;
        else
            Panelotherinfo.Visible = true;




2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 29 Aug 2012, 07:40 AM
Hello,

protected void RadGrid3_PreRender(object sender, EventArgs e)
    {
        if (RadGrid3.MasterTableView.Items.Count == 0)
        {
            Panel1.Visible = false;
        }
        else
        {
            Panel1.Visible = true;
        }
    }

If your grid ajaxify then
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
           <AjaxSettings>
               <telerik:AjaxSetting AjaxControlID="RadGrid3">
                   <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="RadGrid3" />
                       <telerik:AjaxUpdatedControl ControlID="Panel1" />
                   </UpdatedControls>
               </telerik:AjaxSetting>
           </AjaxSettings>
       </telerik:RadAjaxManager>


Thanks,
Jayesh Goyani
0
gc_0620
Top achievements
Rank 1
answered on 29 Aug 2012, 07:32 PM
Thanks Jayesh,

Your solution works. Appreciate for your quick response.

Sincerely
gc_0620
Tags
Grid
Asked by
gc_0620
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
gc_0620
Top achievements
Rank 1
Share this question
or