mixing html source with code behind

  • Thread starter Thread starter miladhatam
  • Start date Start date
M

miladhatam

can i mix the code behind page variables with html source ?
for examle in asp we insert <% %>
i want to connect to my db and with response.write , show it in a table

thanks
 
Yes, you can, but this is not how you do things in asp.net. Asp.net is
object-oriented as opposed to asp that is procedure-oriented. To show the
database content in a table, you should use an asp.net control like GridView
and databind it to your database table. If you use declarative databinding
with DataSourceID property, you can get it done without writing any single
line of code. You will get annoyed and frustrated very soon if you will try
using asp.net in the asp fashion.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
thanks for your answer
but i don't want to use gridview
it is limited and i want to make my table in html source
i don't want to change the construction of my site
 
This is absolutely fine to use an html table. The point is not what control
you are using but how you build the page. Instead of writting directly to
the response stream you could specify what object you want to see in the
rows and databind them. You would likely want to use a repeater in the
following way:

<table>
<asp.repeater ... >
<itemtemplate>
<tr>
<td>some controls</td>
....
<td>some other controls</td>
</tr>
</itemtemplate>
</asp.repeater>
</table>

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
Back
Top