- Data Source parameter settings during nested Data Binding
Problem:
My gridview control is nested in the datalist control. The datalist control has a binding column "quarter". The data source of the gridview control must be retrieved using the value of "quarter.
How do I set parameters for the data source?
Resolution:
1. Set the data source control datatalbe, but it is not a parameter item for the time being. Later, you will dynamically add and modify parameters through method calls, this allows you to Dynamically Retrieve data based on changes in the value of quarter.
2. Bind The gridview1 control to datatalbe and set the format style.
Datasource = '<% # getdatasource (INT) (datarowview) container. dataitem) ["quarter"]) %>'
3. Use the getdatasource method to reset the parameter for datasource of gridview1 based on the value of "quarter", as shown below:
protected sqldatasource getdatasource (int32 parameters)
{< br> sqldatasource SDS = datatable; // the data source control that is configured before but cannot meet the requirements
If (SDS. selectparameters. count = 2) SDS. selectparameters. removeat (1);
SDS. selectparameters. add ("quarter", convert. tostring (parameters);
return SDS;
}