0
我有一個由MDX查詢填充的DataTable。我想將該DataTable綁定到GridView並顯示返回的所有數據。我的GridView的定義如下:GridView不顯示DataTable中的所有列
<asp:GridView ID = "gvResults" runat="server" AutoGenerateColumns="true" />
MDX查詢被稱爲如下:
DataTable mdxResults = new DataTable();
CellSet cellSet;
AdomdCommand command = new AdomdCommand();
strCommand = "SELECT NON EMPTY({[Measures].[Assets Distinct Count], [Measures].[Value]}) " +
"ON COLUMNS, NONEMPTY({[Organization].[Org Id].[Org Id]*[Location].[Loc Id].[Loc Id]}) " +
"ON ROWS FROM [database]"
command.Connection = _CurrentConnection;
command.CommandText = strCommand;
cellSet = command.ExecuteCellSet();
AdomdDataAdapter dataAdapter = new AdomdDataAdapter(command);
objDataAdapter.Fill(mdxResults);
,可以從MDX查詢產生的DataTable的一個例子:
Organization Location Assets Value
Org A Los Angeles 12 320000
Org B San Jose 6 21000
資產和「值」是來自MDX查詢的彙總度量值。
數據表隨後綁定到GridView後重新命名列:
gvResults.DataSource = mdxResults;
gvResults.DataBind();
後我結合數據表僅列的子集在GridView顯示。具體而言,將顯示MDX查詢中除Measure列外的所有列。
任何幫助,將不勝感激。
插入休息,例如DataTable中 – 2014-10-03 13:29:17
可以顯示在您所呼叫的查詢,然後結合的結果代碼DataTable的GridView ..? – MethodMan 2014-10-03 13:29:39