Binding RadGrid on button click?

3 posts, 0 answers
  1. Will
    Will avatar
    6 posts
    Member since:
    Aug 2013

    Posted 06 Sep 2013 Link to this post

    Hi there. I have an aspx page that initially shows a treeview. When a child node on the tree is pressed, i want a RadGrid on the page to be popualated. I set the datasource and do a databind() call but it doesn't seem to be working. I've also tried using needDataSource but it has the same problem. Here's my code:



    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 Telerik.Web.UI;
    using MCMwebapp.Utilities;
     
    namespace MCMwebapp
    {
        public partial class frmLookupTables : System.Web.UI.Page
        {
     
     
            int CurrentDemog;
            bool LookupDataLoaded;
            bool isOPS = false;
            string selectedNode;
     
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                
                }
                 
            }
        
     
     
            protected void LookupsTree_NodeClick(object sender, Telerik.Web.UI.RadTreeNodeEventArgs e)
            {
                
                RadTreeNode currNode = e.Node;
                if (currNode.Nodes.Count == 0) {
                    if (currNode.ParentNode.Text != "Treatments" && !String.IsNullOrEmpty(currNode.Text))
                    {
                        selectedNode = currNode.Text;
                        Session["selectedNode"] = selectedNode;
                        loadLookupGrid();
     
                    }
     
                }
                
            }
     
     
            protected void loadLookupGrid()
            {
                using (ServiceReference1.Service1SoapClient myService = new ServiceReference1.Service1SoapClient())
                {
                    if (Session["selectedNode"] != null)
                    {
                        LookupGrid.DataSource = myService.getTable();
                        LookupGrid.Databind();
     
                    }
                }
             
     
        }
    }

    My aspx code:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmLookupTables.aspx.cs" Inherits="MCMwebapp.frmLookupTables" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
     
        <asp:Label ID="LookupLabel" runat="server"></asp:Label>
     
     
          <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="LookupGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="LookupGrid" LoadingPanelID="TablePanel"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
     
         <telerik:RadAjaxPanel ID="TreePanel" runat="server" HorizontalAlign="NotSet" style="background-color:#808080; float:left" Width="40%">
             
     
             <telerik:RadTreeView ID="LookupsTree" runat="server" OnClientNodeClicked="ClientNodeClicked" OnNodeClick="LookupsTree_NodeClick">
               
            </telerik:RadTreeView>
     
        </telerik:RadAjaxPanel>
     
     
     
         <telerik:RadAjaxLoadingPanel ID="TablePanel" runat="server" HorizontalAlign="Right"
            style="background-color:#E92326; float:right" Width="40%" >
            
        
             <telerik:RadGrid ID="LookupGrid" runat="server" BackColor="Gray"
                 BorderColor="#404040" BorderStyle="Solid" CellSpacing="0" GridLines="None"
                 Skin="MetroTouch">
                 
                 <FilterMenu EnableImageSprites="False">
                 </FilterMenu>
             </telerik:RadGrid>
          
            
         
             
         </telerik:RadAjaxLoadingPanel>
             
     
       <script type="text/javascript">
           function ClientNodeClicked(sender, eventArgs) {
               var node = eventArgs.get_node();
               node.toggle();
           }
           </script>
     
    </asp:Content>

    Any ideas? thanks


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 Sep 2013 Link to this post

    Hi,

    Please try setting the RadGrid outside the RadAjaxLoadingPanel tag. You can set the RadGrid either inside or outside the RadAjaxPanel. Please note that using RadAjaxManager simultaneously with RadAjaxPanel or UpdatePanel ( or implementing multiple wrapped RadAjaxPanels ) is not a supported scenario and we highly recommend to avoid such implementation. Please either use just the manager to update your controls replacing the RadAjaxPanel with a regular asp:Panel, or use the RadAjaxPanel alone to wrap your page.

    Thanks,
    Shinu.
  3. Will
    Will avatar
    6 posts
    Member since:
    Aug 2013

    Posted 09 Sep 2013 Link to this post

    Thanks! I had figured out there was an issue with the loading panel earlier, but thanks for clarifying.
Back to Top