I'm a .NET noob, converting a static HTML site to one that is more dynamic. Part of the site draws a menu like this:
Photo Gallery
Europe
Critters
Family
Garden
Pumpkins
Special Events
Here's the HTML that is generating the menu:
<!--
<TABLE cellSpacing=13 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD>
<DIV class=nav>
<P>Photo Gallery</P>
<P>
<font color=Yellow>Europe (NEW!)</font><BR>
Critters<BR>
Family<BR>
Garden<BR>
Pumpkins<br>
Special Events<BR>
</P>
</DIV>
</TD>
</TR>
</TBODY>
</TABLE>
-->
Pretty simple. What I'm trying to do now is create a User Control that will now generate the menu by selecting distinct Category from tblCategories in an Access database.
But, I'm just getting really confused by where to do all of this. I think it's best to use a datalist, but where do I put the code?
- Do I put a script tag in my MenuRight.ascx file?
- Do it do it in the Codebehind for that same file?
- If I use the connection, adapter, and datalist objects from the toolbar, do I need to write script to connect to the database and bind the data, or is that all taken care of?
Right now, I can't seem to get it to display anything at all. Very frustrated!
Any help would be much appreciated.
SteveWhere to put the code, script tag or code behind? I personally prefer CodeBehind. Until you get yourself better grounded, just put it in the codebehind for your control. As you begin writing more complex applications you might want to separate out the data access into a data access layer and just pass the results back to the control.
Yes, you do need to write the code to open the connection, do the query, bind the data, etc.
Take a look at the quickstart tutorials on this site if you need more.
0 comments:
Post a Comment