t_list.aspx
----------------------------------------------------------------------------------
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master" CodeFile="t_list.aspx.cs" Inherits="t_list" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <strong>台站列表<asp:Panel ID="tlist" runat="server" EnableViewState="False" Height="108px"
        Width="269px">
    </asp:Panel>
    </strong>
</asp:Content>
----------------------------------------------------------------------------------
t_list.aspx.cs
----------------------------------------------------------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Net.NetworkInformation;
using System.Web.UI.HtmlControls;
public partial class t_list : System.Web.UI.Page
{
    private string connstr = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
    protected void Page_Load(object sender, EventArgs e)
    {
        showList();
    }
    private void showList()
    {
        string sql = "select name,id from HouseDetail where type=2 order by name";
        SqlConnection conn = new SqlConnection(connstr);
        SqlCommand cmd = new SqlCommand(sql, conn);
        conn.Open();
        SqlDataReader rd = cmd.ExecuteReader();
        while (rd.Read())
        {
            string strName = rd["name"].ToString();
            string strId = rd["id"].ToString();
            string strURL = "showdetail.aspx?id=" + strId;
            HtmlGenericControl li = new HtmlGenericControl("li");
            li.InnerHtml = "<a href = \"" + strURL + "\">" + strName + "</a>";
            
            tlist.Controls.Add(li);//此处的tlist在调试是报错:当前上下文中不存在名称“tlist”
        }
        conn.Close();
    }
}问问大家怎么回事。