0
我想使用不是SqlDataSource的代碼將數據綁定到網格。如何在Winforms中使用c#代碼在Winforms中將數據綁定到數據透視表網格?
private void Report_Summary_Load(object sender,EventArgs e)
{
string cs= configuraitonManager.connectionString["connectionStringDatabase"].connectionString;
using(SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand("spStoredProcedureTest",con);
cmd.CommandType = CommandType.StoredProcedure;
con.open();
SqlDataReader sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);
pivotGrid.DataSource = ds;
PivotGridField Name = new PivotGridField("Name",PivotArea.RowArea);
PivotGrid.Fields.AddRange(new PivotGridField[] {Name});
Name.AreaIndex = 0;
// My pivot grid name is "pivotGridDemo"
//How to bind the data to the data area,column area and Row area
}
}
我有5場
名稱,標準,城市,年齡,DobYear
我想設置行區域名稱和城市,市列區,年齡和DobYear在數據區
更新
上面的代碼是添加名稱是行字段。但沒有顯示記錄