none
Repeater控件的ItemTemplate中包含LoginView时的异常现象,难道是传说中的BUG? RRS feed

  • 问题

  • 先上代码

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TTTTTTTTTTTTTTTTT.aspx.cs" Inherits="TTTTTTTTTTTTTTTTT" ClientIDMode="Static" %>
    
    
    
    
    
    
    
    <!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">
    
    
    
     <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1" OnItemCommand="Repeater1_ItemCommand">
    
    
    
     <ItemTemplate>
    
    
    
      <asp:LoginView runat="server">
    
    
    
      <AnonymousTemplate>
    
    
    
      </AnonymousTemplate>
    
    
    
      <LoggedInTemplate>
    
    
    
       <asp:Label Text='<%# Eval("Id") %>' runat="server" />
    
    
    
      </LoggedInTemplate>
    
    
    
      </asp:LoginView>
    
    
    
      <asp:LinkButton ID="LinkButton1" CommandName="Refresh" runat="server">LinkButton</asp:LinkButton>
    
    
    
     </ItemTemplate>
    
    
    
     </asp:Repeater>
    
    
    
     <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Guestbook %>" SelectCommand="SELECT * FROM [Note]"></asp:SqlDataSource>
    
    
    
     </form>
    
    
    
    </body>
    
    
    
    </html>
    
    
    
    
    
    
    
    
    using System;
    
    
    
    using System.Collections.Generic;
    
    
    
    using System.Linq;
    
    
    
    using System.Web;
    
    
    
    using System.Web.UI;
    
    
    
    using System.Web.UI.WebControls;
    
    
    
    
    
    
    
    public partial class TTTTTTTTTTTTTTTTT : System.Web.UI.Page
    
    
    
    {
    
    
    
     protected void Page_Load(object sender, EventArgs e)
    
    
    
     {
    
    
    
    
    
    
    
     }
    
    
    
     protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    
    
    
     {
    
    
    
     if (e.CommandName == "Refresh")
    
    
    
     {
    
    
    
      Repeater1.DataBind();
    
    
    
     }
    
    
    
     }
    
    
    
    }
    
    
    
    

    异常现象:

    首次加载页面时,LoggedInTemplate中的Label控件能正常显示Id,点击LinkButton1引起回传之后,无法显示Id,经调试跟踪发现,回传时Repeater1.DataBind()执行数据绑定时,直接把LoginView控件跳过去了,所以数据无法绑定到LoginView控件内部,不知道这是BUG还是需要进行其它的什么设置,或需要写其它代码才行。

    2011年2月28日 8:24