【发布时间】:2013-12-09 07:11:56
【问题描述】:
我有两个网格视图。单击一个网格的一行时,我必须填充另一个网格视图。所以 onClientclick javascript 函数我调用了 ajax,它返回用于填充另一个网格的数据表。现在我被困在如何使用 javascript 绑定网格视图。
这里是代码
<asp:gridview id="gridview1"> .....</asp:gridview>
<asp:gridview id="gridview2"> .....</asp:gridview>
代码隐藏
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton db = (LinkButton)e.Row.Cells[0].Controls[0];
db.OnClientClick = "FunPopulateSecondGrid(" + CType(CType(e.Row.DataItem, System.Data.DataRowView).Row, Label).text + ");"
}
}
javascript
function FunPopulateSecondGrid(productid)
{
$.ajax({
url : '...',
data : { getExEmpList: true, SelectedShop : selectedShop, ajaxCall : true },
method : 'GET',
dataType : 'json',
contentType: "application/json; charset=utf-8",
success : function(data) {
// i am stuck here how to bind it
//gridview2.datasource= data
//gridview2.databind()
},
error : function(xhr, status) {
alert('Sorry, there was a problem while placing your ajax request. Contact Admin!');
}
});
}
【问题讨论】:
标签: javascript jquery asp.net .net ajax