Reputation: 461
I have a database that currently has the tables needed for generating a very basic forum (forum,post,topic and user)
My problem now it displaying this information. I've looked at the in-built features in Visual Studio (GridView
) but they aren't suited for a forum(the look). So I want to be able to design my own look and feel, but I've hit a stone wall. I don't know how to realize the look I want for my website.
This is the code that I have made so far in my C#
file. It basically adds the ForumName to Label1.
cmd.CommandText = "SELECT * FROM forum";
cmd.CommandType = CommandType.Text;
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
reader = cmd.ExecuteReader();
// Data is accessible through the DataReader object here.
while (reader.Read())
{
Label1.Text+=reader.GetString(1);
}
sqlConnection1.Close();
For starters I just want to generate something simple. Like this: http://i45.tinypic.com/1zd55og.jpg
A list that increases in size equal to the amount of forum names found in the table. Preferably I want these ForumNames to be hyperlinks.
If someone can give me a nudge in the right direction I would be most grateful.
Upvotes: 1
Views: 239
Reputation: 4903
The Repeater
is usually a good choice for something simple and totally controllable. It is the most flexible control you can have for iterating some sort of collection and presenting the items accordingly. It doesn't generate any output to the browser, as it lets you specify each part of the particular listing you're building.
<asp:Repeater ID="rptDummy" runat="server">
<HeaderTemplate>
<%--Forum Header here--%>
</HeaderTemplate>
<ItemTemplate>
<%--Forum Item here--%>
</ItemTemplate>
<FooterTemplate>
<%--Forum Footer here--%>
</FooterTemplate>
</asp:Repeater>
Upvotes: 3
Reputation: 2938
You can use GridView, Repeater and Listview.
If you like custom layout like forums
and blogs
, repeater
and listview
might be best choices.
See this to distinguise between them.
Repeater, ListView, DataList, DataGrid, GridView … Which to choose?
Also see the Comparing ListView with GridView,DataList and Repeater
Upvotes: 2
Reputation: 1887
A GridView
is probably what you want for something simple like this. You can change the way that the gridview looks through CSS, nested HTML, etc.
Use <asp:TemplateField ...
to provide your own custom layout.
Upvotes: 1