我有一个最初显示树视图的 aspx 页面。当按下树上的子节点时,我希望填充页面上的 RadGrid。我设置了数据源并进行了 databind() 调用,但它似乎不起作用。我也尝试过使用 needDataSource 但它有同样的问题。这是我的代码:
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();
}
}
}
}
我的aspx代码:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmLookupTables.aspx.cs" Inherits="MCMwebapp.frmLookupTables" %>
<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>