-1

ページに、ユーザーがこの情報を送信したときにユーザーと電子メールをリストするテーブルがあります。このテーブルに投稿ごとに行を追加し、他の行を削​​除しないようにするにはどうすればよいですか?

私のaspx

<table id="tblUsers" class="table table-bordered table-striped">
        <tbody id="tbodyUser">
            <tr>
                <asp:Label ID="lblHeader" Font-Bold="true" runat="server" Visible="false">User to Access</asp:Label>
                <td>
                    <asp:Label ID="lblUser" runat="server" Visible="false"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="lblEmail" runat="server" Visible="false"></asp:Label>
                </td>
            </tr>
        </tbody>
    </table>

私の .cs

protected void btnSendUser_OnClick(object sender, EventArgs e)
{
    string LoginInfo = txtUserAdd.Text;
    PrincipalContext insPrincipalContext = new PrincipalContext(ContextType.Domain, "x.com", "amsndrsecuritysqlser", "xxx");
    UserPrincipal insUserPrincipal = UserPrincipal.FindByIdentity(insPrincipalContext, LoginInfo);


    //it's to first post
    if (lblUser.Visible == false && lblEmail.Visible == false)
    {
        if (insUserPrincipal == null)
        {
            lblError.Visible = true;
        }

        else
        {
            lblUser.Visible = true;
            lblEmail.Visible = true;
            lblHeader.Visible = true;
            lblUser.Text = insUserPrincipal.GivenName + " " + insUserPrincipal.Surname;
            lblEmail.Text = insUserPrincipal.EmailAddress;
        }
    }
}
4

2 に答える 2

2

runat="server"テーブルに追加する必要がありますtblUsers

var row =new System.Web.UI.HtmlControls.HtmlTableRow();
var cell = new System.Web.UI.HtmlControls.HtmlTableCell();
cell.InnerText = "New Cell";
row.Cells.Add(cell);
tblUsers.Rows.Add(row);
于 2013-07-18T18:50:52.233 に答える
0

それはいくつかの可能な解決策の1つです:

  1. コレクションにデータを保存する
  2. ボタンをクリックするたびに、データを更新してセッションに入れます
  3. セッション データをページの Repeater にバインドします (バインディング コードは Page_Load にある必要があります)。

Repeater マークアップは次のようになります

 <asp:Repeater ID="Repeater1" runat="server">
    <HeaderTemplate>
        <table id="tblUsers" class="table table-bordered table-striped">
            <tbody id="tbodyUser">
    </HeaderTemplate>
    <ItemTemplate>
        <tr>
            <asp:Label ID="lblHeader" Font-Bold="true" runat="server" Visible="<% #lblHeaderVisibilty %>">User to Access</asp:Label>
            <td>
                <asp:Label ID="lblUser" runat="server" Visible="<% #lblUserVisibilty %>"></asp:Label>
            </td>
            <td>
                <asp:Label ID="lblEmail" runat="server" Visible="<% #lblEmailVisibilty %>"></asp:Label>
            </td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
        </tbody>
    </table>
    </FooterTemplate>
</asp:Repeater>
于 2013-07-18T19:51:47.690 に答える