mixing html source with code behind

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
 
E

Eliyahu Goldin

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
 
M

miladhatam

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
 
E

Eliyahu Goldin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,265
Latest member
TodLarocca

Latest Threads

Top