0
我創建了具有一個GridView和一個窗體的頁面。我的GridView工作正常。 我的表單有用於用戶名或電子郵件地址的文本框和提交按鈕。此表單也正常工作。將用戶行添加到按鈕單擊的現有網格或表格
在此表單下方,我需要創建一個表格或網格來存儲每個添加的用戶名和電子郵件。 如何創建此表格,以便爲每個btnSendUser_OnClick
事件添加一行?此表格不得刪除先前插入的行。 我的表現在只顯示一行(最近)。
我的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;
}
}