aspxgridview控件模板从表如何动态绑定数据绑定数据

2024-12-17 03:58:30
推荐回答(2个)
回答1:

这个时候你需要找控件
protected void gvDetail_DataBinding(object sender, EventArgs e)
{
ASPxGridView gvDetail = sender as ASPxGridView;
if (gvDetail != null)
{
int i = Convert.ToInt32(gvDetail.GetMasterRowKeyValue());
gvDetail.DataSource = 数据源(根据i取出的)
gvDetail.KeyFieldName = "主键";
}
}

回答2:

DataTable dt = 你封装的类.取数据方法();
grideview.DataSource = dt;
grideview.DataBind();