Saturday, March 24, 2012

mixing html source with code behind

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
thanksYes, 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
<miladhatam@.gmail.com> wrote in message
news:1169715018.059957.129800@.j27g2000cwj.googlegroups.com...
> 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
>
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
<miladhatam@.gmail.com> wrote in message
news:1169764176.065914.13100@.v45g2000cwv.googlegroups.com...
> 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
>
thanks
so i think must use repeater control

0 comments:

Post a Comment