repeater and SQL question

S

SamoK

Hy!

I'm making a little commenting module for news section of my little
homepage. And I don't know how to embed viewing news comments into it.

I have repeater like this:
<asp:Repeater ID="news" Runat="server">
<ItemTemplate>
<table width="100%">
<tr bgcolor="#c6c8b9">
<td class="newsTitle"><%# DataBinder.Eval(Container.DataItem, "Title")%>
</td>
<td width="100" align="right"><%# DataBinder.Eval(Container.DataItem,
"Date")%> </td>
</tr>
<tr bgcolor="#d5d3ca">
<td colspan="2" class="text"><%# DataBinder.Eval(Container.DataItem,
"Body")%><br><br>
<!-- comments goes right here (somewhere) -->
</td>

</tr>
</table>
<br>
</ItemTemplate>
</asp:Repeater>

I then bind datasource to SqlDataSource (.NET 2.0) -- like this -->
news.DataSourceID = NewsDS.ID; (pretty much no interaction going on here).

I have tables news (columns id, title, body, date) and news_comments
(columns id, body, news_id). news_id is a id of a news to which comment
belongs.

What I don't know is, how to select the correct comments and add them into
the repeater (I've commented the place where I want comments to be).

Can anyone help me with any solution?


-- Samo Kralj
 
S

SamoK

One more thing... I want all this to be done once (at the page load),
becouse I have then client side code to expand/collapse those comments (it
isnt seen from code I provided, but I think it is not relavant here).
 
C

Craig Deelsnyder

One more thing... I want all this to be done once (at the page load),
becouse I have then client side code to expand/collapse those comments
(it
isnt seen from code I provided, but I think it is not relavant here).

It sounds like you're doing things very similar to this example from MSDN
magazine:

http://msdn.microsoft.com/msdnmag/issues/03/10/Blogging/default.aspx

I use this blog app myself (well, I did port it to C# w/ some mods) and it
does what you're doing. Your answer and examples are in there.
 
S

SamoK

Thanks Craig... I found that link very useful... and it works now :)
Thanks again!

-- Samo
 

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

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top