日期:2014-05-17  浏览次数:20824 次

ASP.NET前台点击按钮动态增加行
ASP.NET + C#:  
显示图如图
如图:上图为Table的一部分,我想当我点击上面的Add New Row按钮时在紧挨着此按钮的上面添加一行(点一次就添加一行,点多少次就添加多少行)。
前台的部分代码如下

            <tr>
                <th style="width:20%;" rowspan='<%=GetLinCount()%>'>Driver</th>
                <th style="width:35%;">Name</th>
                <th style="width:25%;">Version</th>
                <%--<td style="width:20%;text-align:center;"><asp:CheckBox ID="Driver_CheckBox" runat="server" /></td> --%>
                <td style="width:20%;text-align:center;"></td>                
            </tr>
            <asp:Repeater ID="Repeater_Setting" runat="server" OnItemDataBound="Repeater_Setting_ItemDataBound">
                <ItemTemplate>
                    <tr>
                        <td ><%#Eval("name") %></td>
                        <td ><asp:DropDownList ID="version_DropDownList" runat="server" Width="100%"></asp:DropDownList></td>
                        <td style="width:20%;text-align:center;"><asp:CheckBox ID="Driver_CheckBox" runat="server" /></td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
//就在这里添加行
            <tr>
                <td colspan="4"><asp:Button ID="AddRow_Button" runat="server" Text="Add New Row" Height="31px" Width="112px"/></td>
            </tr>
            <tr>
                <th >EXPECTED RESULTS</th>
                <td colspan="3"><asp:TextBox ID="ExcR