无法将数据库表名称弹出为树视图中的父节点

无法将数据库表名称弹出为树视图中的父节点

本文介绍了无法将数据库表名称弹出为树视图中的父节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%@ Page Title="" Language="C#"  AutoEventWireup="true" CodeFile="ScriptFile.aspx.cs" Inherits="ScriptFile" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:treeview ID="Treeview1" runat="server"></asp:treeview>
</div>
</form>
</body>
</html>







using System;
using System.Data;
using System.IO;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySql.Data.MySqlClient;

public partial class ScriptFile : System.Web.UI.Page
{
    string str;
    MySqlCommand com;
    
    protected void Page_Load(object sender, EventArgs e)
    {
        bindtreeview();
    }

    void bindtreeview()
    {

        MySqlConnection con = new MySqlConnection("Data Source=localhost;Database=utaf;User ID=root;Password=admin;");


        con.Open();
        str = "Select * from scriptgeneratetable";
        com = new MySqlCommand(str, con);
        MySqlDataReader reader = com.ExecuteReader();
        com.Dispose();
        string[,] ParentNode = new string[100, 2];
        int count = 0;
        while (reader.Read())
        {
            ParentNode[count, 0] = reader.GetValue(reader.GetOrdinal("Foldername")).ToString();
            ParentNode[count++, 1] = reader.GetValue(reader.GetOrdinal("textfilename")).ToString();

             
        }
        reader.Close();
        
    }
     
    protected void MyTree_SelectedNodeChanged(object sender, EventArgs e)
    {

    }
}

推荐答案


这篇关于无法将数据库表名称弹出为树视图中的父节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 10:11