How to display data in table using asp.net
<p>Could you help to give me the sample for display data in table using asp.net.</p>

<p>I using sql quory as below:</p>

<pre><code>SELECT 
  pvt.CityName, 
  pvt.[Deluxe Class], 
  pvt.[Superior Class], 
  pvt.[Standard Class] 
FROM (  
  SELECT 
     c 
     .CityName, 
     h.HotelName, 
     tc.TourClass 
   FROM tblCity2 c 
     LEFT JOIN tblTourHotel2 th ON c.CityID = th.CityID 
     LEFT JOIN tblHotel2 h ON th.HotelID = h.HotelID 
     LEFT JOIN tblTourClass2 tc ON th.TourClassID = tc.TourClassID 
   ) t 
   PIVOT ( 
     MAX(HotelName) 
     FOR TourClass IN ([Deluxe Class], [Superior Class], [Standard Class]) 
   )   AS pvt 
</code></pre>

<p>and using table:</p>

<pre><code>   &lt;table class="TableTour2" border="0" cellSpacing="0" cellPadding="0" width="500"&gt;
        &lt;tbody&gt;
          &lt;tr&gt;
            &lt;th scope=col&gt;City&lt;/th&gt;
            &lt;th scope=col&gt;Deluxe Class&lt;/th&gt;
            &lt;th scope=col&gt;Superior Class&lt;/th&gt;
            &lt;th scope=col&gt;Standard Class&lt;/th&gt;
          &lt;/tr&gt;
          &lt;%
              Dim cnnPH As New System.Data.SqlClient.SqlConnection
              Dim drPH As System.Data.SqlClient.SqlDataReader
              Dim cmdPH As System.Data.SqlClient.SqlCommand
               Try
                  cnnPH.ConnectionString = ConStr
                  cnnPH.Open()
                  cmdPH = New System.Data.SqlClient.SqlCommand("SELECT pvt.CityName, pvt.[Deluxe Class], pvt.[Superior Class], pvt.[Standard Class] " &amp; _
                                                                  " FROM (  SELECT " &amp; _
                                                                  " c.CityName, h.HotelName, tc.TourClass " &amp; _
                                                                  " FROM tblCity2 c  " &amp; _
                                                                  " LEFT JOIN tblTourHotel2 th ON c.CityID = th.CityID " &amp; _
                                                                  " LEFT JOIN tblHotel2 h ON th.HotelID = h.HotelID " &amp; _
                                                                  " LEFT JOIN tblTourClass2 tc ON th.TourClassID = tc.TourClassID " &amp; _
                                                                  " WHERE th.TourID='1' " &amp; _
                                                                  " ) t " &amp; _
                                                                  " PIVOT ( MAX(HotelName) FOR TourClass IN ([Deluxe Class], [Superior Class], [Standard Class]) " &amp; _
                                                                  " ) AS pvt", cnnPH)

                  drPH = cmdPH.ExecuteReader
                  While drPH.Read
           %&gt; 
         &lt;tr&gt;
            &lt;th class=sub&gt;&lt;%Response.Write(drPH("CityName"))%&gt; &lt;/th&gt;
            &lt;td&gt;&lt;%  Response.Write(drPH("HotelName"))%&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%  Response.Write(drPH("HotelName"))%&gt;&lt;/td&gt;
            &lt;td&gt;&lt;%  Response.Write(drPH("HotelName"))%&gt;&lt;/td&gt;
          &lt;/tr&gt;
              &lt;%  

              End While
                  drPH = Nothing
                  cnnPH.Close() : cnnPH = Nothing
          Catch ex As Exception
              MsgBox(ex.Message)
              drPH = Nothing
              cnnPH.Close() : cnnPH = Nothing
          End Try
%&gt;
         &lt;/tbody&gt;
      &lt;/table&gt;
</code></pre>

<p>sorry for something wrong becuase I am not good with sql and asp.net program.</p>

<p>I am wiating for your help</p>

<p>many thanks
Kosal</p>
