我有一个数据库,我需要将其转换为网页列表。我将数据绑定到后台代码文件的 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 或其他内容,将列表项向下移动一点以腾出空间?