我想使用不是 SqlDataSource 的代码将数据绑定到透视网格。
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
更新
上面的代码是添加 Name is Row 字段。但不显示记录