我在这里想念什么,以便我的asp:Repeater不起作用?

时间:2010-06-24 10:46:55

标签: asp.net controls repeater data-binding

我有这堂课:

public class RateResultsSummary
{
    public RateResultsSummary(string labelText, string dataText)
    {
        LabelText = labelText;
        DataText = dataText;
    }

    private string _labelText;
    public string LabelText
    {
        get { return _labelText; }
        set { _labelText = value; }
    }

    private string _dataText;
    public string DataText
    {
        get { return _dataText; }
        set { _dataText = value; }
    }
}

我的.aspx页面包含:

    <body>
        <form id="form1" runat="server">
        <div>
        <fieldset id="fsetSummaryLeastCostOption" runat="server" style="width: 200px;" visible="false">
        <legend>SUMMARY LEAST COST OPTION</legend>
        <asp:Repeater ID="repSummary" runat="server">
            <ItemTemplate>
             <asp:Label ID="lblLabel" runat="server"  
              Text='<%# ((RateResultsSummary)Container.DataItem).LabelText %>'></asp:Label>
            <asp:Label ID="lblData" runat="server"  
Text='<%# ((RateResultsSummary)Container.DataItem).DataText %>'></asp:Label>
                 <asp:Label ID="lbl" runat="server" Text="Some static text"></asp:Label>
            <br />
            </ItemTemplate>
        </asp:Repeater>
    </fieldset>
        </div>
        </form>
    </body>

我以这样的方式绑定它:

 protected void Page_Load(object sender, EventArgs e)
    {

        List<RateResultsSummary> lstRateResultDataSource = new List<RateResultsSummary>();
        lstRateResultDataSource.Add(new RateResultsSummary("Carrier: ", "Xxx"));
        lstRateResultDataSource.Add(new RateResultsSummary("Mode: ", "Yyyy"));
        lstRateResultDataSource.Add(new RateResultsSummary("Service: ", "Zzz"));
        lstRateResultDataSource.Add(new RateResultsSummary("Transit: ", "Ccccc"));
        lstRateResultDataSource.Add(new RateResultsSummary("Total Cost: ", "Kkkkk"));

        repSummary.DataSource = lstRateResultDataSource;
        repSummary.DataBind();

    }

我只得到一个空白页面。

我错过了什么吗?

由于

1 个答案:

答案 0 :(得分:3)

你错过了

visible="false"

在第三行... fieldset id =“fsetSummaryLeastCostOption”......