当调试器说应该有2时,表只显示1行

时间:2015-04-13 07:30:29

标签: c# asp.net

我正在制作一个网络应用程序,它允许您内联创建新项目(尚未保存) 无论如何,添加第一行没有问题,显示就好了 然后,当我添加第二个甚至第三个时,它只会显示我添加的最后一行。 我试过谷歌搜索它,但无济于事。

asp.net页面:

                <div class="row">
                <div class="col-md-3">
                    <label for="tbAdress"><%:accContacts %>:</label>
                </div>
                <div class="col-md-9">
                    <asp:Table ID="tblContactsOverview" runat="server" CssClass="table table-striped">
                        <asp:TableHeaderRow>
                            <asp:TableHeaderCell><%:conFirstName %></asp:TableHeaderCell>
                            <asp:TableHeaderCell><%:conLastName %></asp:TableHeaderCell>
                            <asp:TableHeaderCell>E-mail</asp:TableHeaderCell>
                            <asp:TableHeaderCell><%:contactsTelnr %></asp:TableHeaderCell>
                            <asp:TableHeaderCell ID="AddContactHead" runat="server"><button type="button" class="btn btn-default btn-sm" data-toggle="modal" data-target="#addContact"><i class="glyphicon glyphicon-plus"></i></button>
                            </asp:TableHeaderCell>
                        </asp:TableHeaderRow>
                    </asp:Table>
                </div>
            </div>

c#c​​ode:

        private void contactsRows(string c1, string c2,string c3, string c4)
    {
        TableRow row = new TableRow();
        TableCell cell1 = new TableCell();
        TableCell cell2 = new TableCell();
        TableCell cell3 = new TableCell();
        TableCell cell4 = new TableCell();
        TableCell cell5 = new TableCell();
        cell1.Text = c1;
        cell2.Text = c2;
        cell3.Text = c3;
        cell4.Text = c4;
        cell5.Text = "<span class=\"label label-success\">NEW</span>";
        row.Cells.Add(cell1);
        row.Cells.Add(cell2);
        row.Cells.Add(cell3);
        row.Cells.Add(cell4);
        row.Cells.Add(cell5);
        //todo prevent reset
        tblContactsOverview.Rows.Add(row);
        tbConEmail.Value = string.Empty;
        tbConFirstname.Value = string.Empty;
        tbConLastname.Value = string.Empty;
        tbConPhone.Value = string.Empty;
    }

旁注:我已经在项目中包含了Jquery,尽管我认为它不会影响到这个表。

0 个答案:

没有答案