Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 单击按钮将用户行添加到现有网格或表中_C#_Asp.net_.net - Fatal编程技术网

C# 单击按钮将用户行添加到现有网格或表中

C# 单击按钮将用户行添加到现有网格或表中,c#,asp.net,.net,C#,Asp.net,.net,我创建了一个包含一个GridView和一个表单的页面。我的GridView工作正常。 我的表单有一个用于输入用户名或电子邮件地址的文本框和一个提交按钮。此表单也正常工作 在这个表单下面,我需要创建一个表或网格来存储添加的每个用户名和电子邮件。 如何创建此表,以便为每个btnSendUser\u OnClick事件添加一行?此表不能删除以前插入的行。 我的表格现在只显示一行(最近的一行) 我的aspx <asp:GridView ID="GridView" runat="server" Au

我创建了一个包含一个GridView和一个表单的页面。我的GridView工作正常。 我的表单有一个用于输入用户名或电子邮件地址的文本框和一个提交按钮。此表单也正常工作

在这个表单下面,我需要创建一个表或网格来存储添加的每个用户名和电子邮件。 如何创建此表,以便为每个
btnSendUser\u 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>

您应该使用设计用于处理值集合的组件,例如另一个网格

如果太重,您可以按如下方式更新标签:

lblUser.Text = lblUser.Text 
             + insUserPrincipal.GivenName + " " + insUserPrincipal.Surname
             + "<br />";
lblEmail.Text = lblEmail.Text
              + insUserPrincipal.EmailAddress
              + "<br />";
lblUser.Text=lblUser.Text
+inUserPrincipal.GivenName+“”+inUserPrincipal.姓氏
+“
”; lblEmail.Text=lblEmail.Text +inUserPrincipal.EmailAddress +“
”;
lblUser.Text = lblUser.Text 
             + insUserPrincipal.GivenName + " " + insUserPrincipal.Surname
             + "<br />";
lblEmail.Text = lblEmail.Text
              + insUserPrincipal.EmailAddress
              + "<br />";