页面代码:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %><!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 runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        &nbsp;</div>
        <asp:DataList ID="DataList1" runat="server" Width="226px" CellPadding="4" ForeColor="#333333">
        <ItemTemplate>
           <%# Eval("id")%>
           </ItemTemplate>            
        </asp:DataList>&nbsp;
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
    </form>
</body>
</html>
CS代码:
 
    protected void buildList()
    {
        DataSet ds = new DataSet();        using (SqlConnection MyConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["conn1"].ConnectionString))
        {
            string strSql = "select id from Store";            SqlDataAdapter da = new SqlDataAdapter(strSql, MyConn);
           
            da.Fill(ds,"Store");
            this.DataList1.DataSource = ds.Tables["0"];
            this.DataList1.DataBind();        }
    }    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            buildList();
        }
    }奇怪的是点击按钮时在DataList中什么都不显示?这是什么原因?谢谢!