How do I create a DataGrid if the column names are generated dynamically in the SQL query? For eg if the column names are<BR>generated like this:<BR><BR>strSQL1="SELECT DISTINCT(ErnCode) AS ErnCode FROM ALLV"<BR>objDapter1=New SQLDataAdapter(strSQL1,objConn)<BR>objDapter1.Fill (dTable)<BR><BR>Dim strSQL2 As New StringBuilder("SELECT DISTINCT(em.ECode),em.EName,")<BR>For Each dRow In dTable.Rows<BR>strErnCode=dRow.Item(0).ToString<BR >strSQL2.Append("(SELECT SUM(allv.Amt) FROM ALLV AS allv WHERE allv.ErnCode=&#039;")<BR>strSQL2.Append(strErnCode )<BR>strSQL2.Append("&#039; AND em.ECode=allv.ECode AND MONTH(allv.Date)=4) AS ")<BR>strSQL2.Append(strErnCode)<BR>strSQL2.Append (",")<BR>Next<BR>strSQL2.Append(" FROM EMST AS em,ALLV AS allv WHERE em.ECode=allv.ECode ORDER BY em.ECode")<BR>strSQL2.Replace(", FROM"," FROM")<BR>.........................<BR>myDG.DataBi nd()<BR><BR>As you can see, the alias column names in the 2nd SQL query are being generated dynamically depending upon what records are being<BR>retrieved by the 1st SQL query. The records of the 1st 2 columns (ECode & EName) retrieved by the 2nd query can be displayed in<BR>the DataGrid as follows:<BR><BR>&#060;asp:DataGrid id="myDG" runat="server"&#062;<BR>&#060;Columns&#062;<BR>&#0 60;asp:BoundColumn HeaderText="E.CODE" DataField="ECode" runat="server"/&#062;<BR>&#060;asp:BoundColumn HeaderText="EMPLOYEE NAME" DataField="EName" runat="server"/&#062;<BR>&#060;/Columns&#062;<BR>&#060;/asp:DataGrid&#062;<BR><BR>But how do I display the records retrieved by the other columns (i.e. other than the ECode & the EName columns) in the DataGrid<BR>that are being fetched by the 2nd SQL query as the rest of the column names are being generated at runtime & hence I am not aware of the rest of the column names at design time? Had I known the column names at design time, then the records could have been displayed in the same way as how the records of the ECode & the EName columns are displayed in the DataGrid code sample shown above.<BR><BR>Thanks,<BR><BR>Arpan