【发布时间】:2021-11-29 02:58:38
【问题描述】:
我想通过asp.net中的数据表在asp gridview中添加按钮
这是我的 gridview 代码,
<asp:GridView ID="gv_productdetail" runat="server" AutoGenerateColumns="false" CssClass="table table-bordered table-condensed">
<columns>
<asp:BoundField DataField="MortageID" HeaderText="Id" />
<asp:BoundField DataField="Type" HeaderText="Type" />
</columns>
</asp:GridView>
现在,这个 gridview 是通过 ajax 方法绑定的。这是代码,
//Fill Product Grid
function FillProductGrid() {
//Display Product
var AcNo = document.getElementById('<%= txt_acno.ClientID%>').value;
var Data = JSON.stringify({ mortgageNo: MortgageNo, acNo: AcNo });
$.ajax({
url: "CustomerMortgage.aspx/GetProductList",
async: true,
type: "POST",
dataType: "json",
data: Data,
contentType: "application/json; charset=utf-8",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
$('#<%=gv_productdetail.ClientID%>').DataTable(
{
paging: false,
destroy: true,
bLengthChange: true,
lengthMenu: [[5, 10, -1], [5, 10, "All"]],
bFilter: true,
bSort: true,
bPaginate: true,
data: response.d,
columns: [{ 'data': 'ProductId' },
{ 'data': 'ProductType' }
});
};
整个数据被完美绑定。但是现在我想在每一列中添加按钮,我尝试了 asp:TemplateField 但它不起作用。
【问题讨论】:
标签: jquery asp.net ajax gridview datatable