0

我有一个 radtreeview,它由后面的代码中的数据库填充。我有一个想要触发的简单点击功能,但它似乎不起作用。这可能很简单。后面的代码有点难看,但没有做任何复杂的事情。这是我的 aspx 和后面的代码:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmMain.aspx.cs" Inherits="MCMwebapp.frmMain" %>

 <script type="text/javascript" language="javascript">
     function ClientNodeClicked(sender, eventArgs) {
         var node = eventArgs.get_node();
         alert("You clicked " + node.get_text());
     }

由于某种原因,结束脚本标签没有显示在编辑器上。

   < telerik:RadTreeView ID="sitesTree" runat="server" OnClientNodeClicked="ClientNodeClicked">
            <WebServiceSettings Path="MCMwebservice.Service1.asmx" Method="" />
    </telerik:RadTreeView>

这是填充我的树的函数:

  public void LoadSites(ref RadTreeView TreeSites, string Demogs, string Agencies, bool Config)
    {
        // Declare the SslConnection class variable.
        SqlConnection sStateConn = new SqlConnection(Util.ConStrEpcrProd);
        SqlConnection sZonesConn = new SqlConnection(Util.ConStrEpcrProd);
        SqlConnection sAgenciesConn = new SqlConnection(Util.ConStrEpcrProd);
        SqlCommand sStatesCmd = new SqlCommand("SELECT DISTINCT State FROM AMR_ZONE WHERE Zone_ID IN (" + Demogs + ") ORDER BY State");
        SqlCommand sZonesCmd = new SqlCommand();
        SqlCommand sAgenciesCmd = new SqlCommand();
        sZonesCmd.Connection = sZonesConn;
        sAgenciesCmd.Connection = sAgenciesConn;
        sStatesCmd.Connection = sStateConn;
        SqlDataReader objZonesReader;
        SqlDataReader objAgenciesReader;
        SqlDataReader objStateReader;

        try
        {
            sStateConn.Open();
            sZonesConn.Open();
            sAgenciesConn.Open();

            objStateReader = sStatesCmd.ExecuteReader();
            TreeSites.Nodes.Add(new RadTreeNode("MEDS", "MEDSRoot"));


            while (objStateReader.Read())
            {
                RadTreeNode StateNode = new RadTreeNode(objStateReader["State"].ToString());
                StateNode.Text = objStateReader["State"].ToString();

                (TreeSites.FindNodeByText("MEDS")).Nodes.Add(StateNode);

                sZonesCmd.CommandText = "SELECT State,County,Zone_ID FROM AMR_ZONE WHERE State = '" + objStateReader["State"].ToString() + "' AND Zone_ID IN (" + Demogs + ") ORDER BY County";
                objZonesReader = sZonesCmd.ExecuteReader();

                while (objZonesReader.Read())
                {
                    RadTreeNode ZoneNode = new RadTreeNode(objZonesReader["County"].ToString());
                    ZoneNode.Text = objZonesReader["Zone_ID"].ToString();
                    bool p = ZoneNode.PostBack;
                    (TreeSites.FindNodeByText("MEDS")).Nodes[StateNode.Index].Nodes.Add(ZoneNode);
                    if (!Config)
                    {
                        // If the sites are being loaded to grant user permissions, then load the agencies as well.
                        sAgenciesCmd.CommandText = "SELECT [DESC], CODE, Demog FROM AMR_AGEN WHERE Demog = " + ZoneNode.Text + " AND CODE IN(" + Agencies + ") ORDER BY [DESC]";
                        objAgenciesReader = sAgenciesCmd.ExecuteReader();

                        while (objAgenciesReader.Read())
                        {
                            RadTreeNode AgencyNode = new RadTreeNode(objAgenciesReader["DESC"].ToString());
                            //AP 1/24/2010 changed to name the node with the CODE value
                            //AgencyNode.Name = objAgenciesReader["DESC"].ToString();
                            AgencyNode.Text = objAgenciesReader["CODE"].ToString();
                            AgencyNode.Value = objAgenciesReader["CODE"].ToString() + objAgenciesReader["Demog"].ToString();
                            (TreeSites.FindNodeByText("MEDS")).Nodes[StateNode.Index].Nodes[ZoneNode.Index].Nodes.Add(AgencyNode);
                        }

                        objAgenciesReader.Close();
                        objAgenciesReader.Dispose();
                    }
                }

                objZonesReader.Close();
                objZonesReader.Dispose();
            }

            objStateReader.Close();
            objStateReader.Dispose();

        }
        catch (SqlException SqlEx)
        {
            MessageBox.Show("Database error. Please contact your administrator. LoadSite(): "
                + SqlEx.Message, "MEDS Configuration Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        catch (Exception ex)
        {
            MessageBox.Show("Error -  LoadSite(): "
                + ex.Message, "MEDS Configuration Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        finally
        {
            sStateConn.Close();
            sStateConn.Dispose();
            sAgenciesConn.Close();
            sAgenciesConn.Dispose();
            sZonesConn.Close();
            sZonesConn.Dispose();
            sStatesCmd.Dispose();
            sZonesCmd.Dispose();
            sAgenciesCmd.Dispose();
        }
    }//      



}
4

1 回答 1

0

尝试改变这一点:

< telerik:RadTreeView ID="sitesTree" runat="server" ...

进入这个:

<telerik:RadTreeView ID="sitesTree" runat="server" ...
于 2013-08-27T20:23:52.447 回答