0

我有一个数据库,我需要将其转换为网页列表。我将数据绑定到后台代码文件的 page_load 函数中的网格视图。我想知道如何获取我的网格数据并用它创建一个 ul/li 列表。到目前为止,这是我的功能:

    protected void Page_Load(object sender, EventArgs e)
    {

        Service1 myService = new Service1();

        //Use a gridview to store the table data before building the menu
        GridView sites = new GridView();

        sites.DataSource = myService.GetAllSites();
        sites.DataBind();



        foreach (GridViewRow siteRow in sites.Rows)
        {

            String itemName = siteRow.Cells[1].Text;              

        }

另外,有谁知道如何使列表可扩展?因此,单击一个列表项会导致在其下方打开一个 div 或其他内容,将列表项向下移动一点以腾出空间?

4

1 回答 1

0

你所描述的听起来非常接近 asp.netTreeView控件

http://msdn.microsoft.com/en-us/library/d4fz6xk2(v=vs.80).aspx

添加到树:

treeView1.Nodes.Add(new TreeNode(site.Name));

这里有一个很容易理解的例子:

http://www.nullskull.com/q/10328363/treeview-in-aspnet-with-examples.aspx

于 2013-08-08T04:18:58.247 回答