如何在客户端将行添加到转发器 [英] How to add rows to a repeater in client side
问题描述
我有一个 Repeater
和一个 Button
.如果单击我的按钮,则需要在客户端(Javascript)的中继器中创建新的行.我可以在服务器端执行此操作,但要避免回发.我没有使用Ajax Updatepanel
控件.此外,我在我的 Repeater
中使用表结构.
I have a Repeater
and also a Button
. If I click on my button a new rows need to be created to the repeater in client side (Javascript). I am able to do this with server side, but want to avoid a postback. I am not using an Ajax Updatepanel
control. Moreover I am using a table structure in my Repeater
.
推荐答案
由于您的 Repeater
只是生成一个表,因此这里有一些可在表中添加一行的javascript.
Since your Repeater
is just producing a table, here is some javascript to add a row to a table.
function AddRowToTable()
{
// Add your table name to the getElementById
var table = document.getElementById("yourTableID");
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
// Create any cells and elements you need
var cell1 = row.insertCell(0);
var element1 = document.createElement("input");
element1.type = "text";
cell1.appendChild(element1);
// repeat for more cells / elements as required
}
这只是将其添加到客户端,因此,如果要使其回发,则需要使用将要发布其数据的元素来存储数据.
This will just add it client side though so if you want it to postback you will need to store the data using elements that will post their data.
这篇关于如何在客户端将行添加到转发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!