@Rex 做你的例子的方法很简单。做一些中继器控制
<table id="suppliers" >
<tbody>
<asp:Repeater ID = "rptSuppliers" runat = "server">
<ItemTemplate>
<tr style = "padding:10px;" class = "supplier" tag = '<%# Eval("ID") %>' id = 'supplier_<%# Eval("ID") %>'>
<td style = "width:200px;">ספק: <%# Eval("Supplier.Group.GroupName") %></td>
<td style = "width:200px;">איש קשר: <%# Eval("Supplier.Profile.ProfileData.FullName")%></td>
<td>מחיר:
<%--כדי שהולדיאציה תבוצע כיאות לשדה צריך להיות שם ומזהה זהים אבל ייחודיים--%>
<input class = "required price" name ="price<%# Eval("Supplier.ID") %>" id = "price<%# Eval("Supplier.ID") %>" type="text" value = '<%# Eval("Price","{0:n2}") %>' min ="0" style ="width:60px;"/>
<input class ="supplier_id" type ="hidden" value = '<%# Eval("Supplier.ID") %>' />
</td>
<td style = "padding-right:10px;">
<img src ="../../Images/remove40_32x32.gif" height ="16" width = "16" title = 'הסר' style = "float:right;" id = "sremove"
onclick = "removeClick(this)"
onmouseout = "removeOut(this)"
onmouseover = "removeOver(this)" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</tbody>
</table>
只是绑定onload一些数据
rptSuppliers.DataSource = product.Suppliers;
rptSuppliers.DataBind();
最重要的是客户端。您可以为转发器制作一些相同的内容模板,模板由 mTamplate jquery 插件生成。
<script type="text/html" id="suppliers_tmpl">
<tr style = "padding:10px;" class = "supplier" tag = '<#= ID #>' id = 'supplier_<#= ID #>'>
<td style = "width:200px;">ספק: <#= Supplier #></td>
<td style = "width:200px;">איש קשר: <#= Contact #></td>
<td>מחיר:
<input class = "required price" name ="price<#= SupplierID #>" id = "price<#= SupplierID #>" type="text" value = '<#= Price #>' min ="0" style ="width:60px;"/>
<input class ="supplier_id" type ="hidden" value = '<#= SupplierID #>' />
</td>
<td style = "padding-right:10px;"><img src ="../../Images/remove40_32x32.gif" height ="16" width = "16" title = 'הסר' style = "float:right;" id = "sremove"
onclick = "removeClick(this)"
onmouseout = "removeOut(this)"
onmouseover = "removeOver(this)" />
</td>
</tr>
</script>
然后如果你想把这个模板附加到你的桌子上
function UpdatesupplierItem(supplier) {
// Retrieve the Item template
var template = $("#suppliers_tmpl").html();
// Parse the template and merge stock data into it
var html = parseTemplate(template, supplier);
// Create jQuery object from gen'd html
var newItem = $(html);
var item_id = "supplier_" + supplier.SupplierID;
//נוסיף פריט רק במידה ואיננו קיים
var origItem = $("#" + item_id);
if (origItem.length < 1)
newItem.appendTo("#suppliers tbody");
else
origItem.after(newItem).remove();
return newItem;
}
使您的 html 元素可用于 jquery(通过 id 或类)。去吧。
更多信息west-wind
那里你可以得到一些指向源的链接,你有很多例子..