ASPxGridView1用法2
父控件中一定要邦定主键,KeyFieldName="sheet_no";
接下来就是后台邦定代码了,如何邦定我父控件,前面都说过了,接下来,我们看如何邦定子控件,因为子控件在后台调不出来,所以,我再加一个SqlDataSource控件,用它来邦定子控件,这个邦定要动态的去,在展开行事件中写
private void NewMethod(int i)
{
//得到主键值
object var = this.grid.GetRowValues(i, new string[] { "sheet_no" });
this.SqlDataSource1.DataSourceMode = SqlDataSourceMode.DataReader;
this.SqlDataSource1.ConnectionString = "Server=.;DataBase=hjh02;uid=sa;pwd=1";
this.SqlDataSource1.SelectCommand = string.Format("select * from lsps_bhqd where sheet_no='{0}'", var.ToString());
this.SqlDataSource1.DataBind();
}
//展开行事件
protected void grid_DetailRowExpandedChanged(object sender, ASPxGridViewDetailRowEventArgs e)
{
NewMethod(e.VisibleIndex);
}