|
-
Sep 7th, 2004, 05:18 AM
#1
How to create a table like VBF? (RESOLVED)
I have a table, Feedback.
I would like to display this data like VBF displays it's threads...In a grid thing.
I am sick of seeing code, but having no idea what to do with it, or where to place it in my code?
Can anyone help me?
I crash course of style sheets would be good.
Woof
Last edited by Wokawidget; Sep 8th, 2004 at 06:16 PM.
-
Sep 7th, 2004, 10:11 AM
#2
Addicted Member
You could bind it to the datagrid control. The control already has styles and such much like the design of VBF built in. Just use the auto format. It works rather well for displaying data and its really easy to use.
-
Sep 7th, 2004, 10:16 AM
#3
Re: How to create a table like VBF?
Originally posted by Wokawidget
I have a table, Feedback.
I would like to display this data like VBF displays it's threads...In a grid thing.
I am sick of seeing code, but having no idea what to do with it, or where to place it in my code?
Can anyone help me?
I crash course of style sheets would be good.
Woof
Woka, you could either use DataGrid or DataRepeater control. DataRepeater is more flexible if you wish to construck output with embeded tables.
It is simple to use.
First get your data into a DataSet and set the datasource property of the DataRepeater to dataset. Assuming you placed a Repeater Control called rpPost in the form. The following would go in the Page Load.
Code:
rpPost.DataSource=ds;
rpPost.DataMember="Post";
rpPost.DataBind();
Now the HTML for the page. You need to define three sections :
1. Header (e.g the table header, Here we open table)
2. Item Template (any code here gets looped, so in effect this is a loop)
3. Footer (any footer text, here we close the table)
Here is an example i stripped down from my ASP.Net forum
Hope this helps.
VB Code:
<BODY>
<center>
<h1 align="center"><% Response.Write(Thread_Title);%></h1>
<form id="thread" method="post" runat="server">
<asp:repeater id="rpPost" runat="server">
<HeaderTemplate>
<table bgcolor="LightBlue" width="90%" cellpadding="5" cellspacing="1">
<tr>
<td class="tableborder">Author</td>
<td class="tableborder"><b><% Response.Write (Thread_Title); %></b></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr bgcolor="white">
<td width="20%" valign="top">
<b>
<%
string s;
s="<a href='GetUser.aspx?UserId=" + ds.Tables["Post"].Rows[i]["UserId"].ToString() + "'>" + ds.Tables["Post"].Rows[i]["Username"].ToString() + "</a>";
Response.Write (s);
%>
<br>
</b>
</td>
<td bgcolor="White">
<b>
<%# DataBinder.Eval(Container.DataItem, "PostTitle") %>
</b>
</td>
</tr>
<tr>
<td class="tableborder"><%# DataBinder.Eval(Container.DataItem, "Time_Created") %></td>
<td class="tableborder" align="right">
<table border="0">
<tr>
<td align="right"><a href='DeletePost.aspx?PostId=<%# DataBinder.Eval(Container.DataItem, "PostId") %>'>Delete</a></td>
<td align="right"><a href='reply.aspx?ThreadId=<%# DataBinder.Eval(Container.DataItem, "ThreadId")%>&PostId=<%# DataBinder.Eval(Container.DataItem, "PostId")%>'>Quote</a></td>
</tr>
</table>
</td>
</tr>
<%
i++;
%>
</ItemTemplate>
<FooterTemplate>
<tr>
<td class="tableborder" colspan="2" align="right">
<%
string lnk;
lnk="JavaScript:window.location='reply.aspx?ThreadId=" + threadid + "';" ;
%>
<input type="button" value="Reply" class="bttn" onclick="<% Response.Write(lnk);%>">
</td>
</tr>
</table>
</FooterTemplate>
</asp:repeater>
</center>
</FORM>
</BODY>
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Sep 8th, 2004, 06:15 PM
#4
I have used an XSL file, a CSS file and an ASP XML Control on my page.
This I have found is WAY easier than using a datalist, or another control. Well, I think so anyways.
I have also been told that this is a much better way of doing it...would this be right? I can see how it would be.
Woka
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|