0

1 つの GridView と 1 つのフォームを含むページを作成しました。私の GridView は正常に動作しています。私のフォームには、ユーザー名または電子メール アドレス用の TextBox と送信ボタンがあります。このフォームも正常に動作しています。

このフォームの下に、追加された各ユーザー名と電子メールを格納するテーブルまたはグリッドを作成する必要があります。btnSendUser_OnClickイベントごとに 1 つの行が追加されるような方法でこのテーブルを作成するにはどうすればよい ですか? このテーブルは、以前に挿入された行を削除してはなりません。テーブルには 1 行 (最新の行) しか表示されません。

私のaspx

<asp:GridView ID="GridView" runat="server" AutoGenerateColumns="false" GridLines="None"
        CssClass="table table-bordered table-striped">
        <Columns>
            <asp:BoundField DataField="AccessGroup" HeaderText="Access Group" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Business Justification">
                <ItemTemplate>
                    <asp:TextBox ID="txtJustBuss" runat="server" Height="17px" Width="150px"></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <asp:Label ID="lblUserAdd" runat="server" Font-Bold="true" Text="Add User - (Email or User Name)"></asp:Label>
    <br />
    <asp:TextBox ID="txtUserAdd" runat="server" Height="17px" Width="150px"></asp:TextBox>
    <asp:Label ID="lblError" runat="server" class="control-label" for="inputError" Visible="false">Input with error</asp:Label>
    <asp:Button ID="btnAddUser" class="btn" runat="server" Font-Bold="true" Text="Add User"
        OnClick="btnSendUser_OnClick" />
    <br />
    <br />
    <table id="tblUsers" class="table table-bordered table-striped" runat="server" visible="false">
        <tbody>
            <tr>
                <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", "amsuser", "xx");
    UserPrincipal insUserPrincipal = UserPrincipal.FindByIdentity(insPrincipalContext, LoginInfo);

    if (insUserPrincipal == null)
    {
        lblError.Visible = true;
    }

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

1 に答える 1