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

Binding RadGrid on button click?

2 Answers 81 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Will
Top achievements
Rank 1
Will asked on 06 Sep 2013, 06:22 PM
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 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 09 Sep 2013, 03:50 AM
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.
0
Will
Top achievements
Rank 1
answered on 09 Sep 2013, 04:09 PM
Thanks! I had figured out there was an issue with the loading panel earlier, but thanks for clarifying.
Tags
General Discussions
Asked by
Will
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Will
Top achievements
Rank 1
Share this question
or