2014-10-03 2 views
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 쿼리의 집계 된 계수입니다. I는 컬럼의 서브 세트 만이 표시에서의 GridView DataTable의 결합 후

gvResults.DataSource = mdxResults; 
gvResults.DataBind(); 

: I 컬럼 이름을 변경 한 후

DataTable에

는 다음의 GridView에 결합된다. 특히 MDX 쿼리의 측정 열을 제외한 모든 열이 표시됩니다.

도움을 주시면 감사하겠습니다.

+0

나머지 GridView 코드를 삽입하고 DataTable –

+0

의 예를 사용하면 쿼리를 호출하는 코드를 표시 한 다음 결과를 바인딩 할 수 있습니까? Gridview에 DataTable의 ..? – MethodMan

답변

0

MDX 쿼리가 AutoGenerateColumns에서 지원하지 않는 측정 결과에 대해 Object 형식의 DataTable을 채우는 문제가 발생했습니다. 이 문제를 해결하기 위해 GridView에 바인딩하기 전에 DataType을 변경하기 위해 솔루션을 활용했습니다. How To Change DataType of a DataColumn in a DataTable?

관련 문제