How do I read a CSV into a HTML Table?
*** SOLVED ***
I have a file that I want to read called "links". It's a csv along the lines of:
Name of Site, Link
All I want to do is read the file and use each line to create a table element. I've no clue what to do,could someone point me to a tutorial? Here's what I have:
musicians.aspx.cs
Code:
using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class musicians : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
StreamReader SR;
string S;
SR = File.OpenText("c:\\inetpub\\wwwroot\\links");
S=SR.ReadLine();
while(S!=null)
{
S=SR.ReadLine();
}
SR.Close();
}
}
musicians.aspx
Code:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="musicians.aspx.cs" Inherits="musicians" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Repeater ID="myTable" runat="server">
<HeaderTemplate>
<table>
<tr>
<th>Music Group</th>
<th>Website</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
</td>
</tr>
</ItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:Repeater>
</asp:Content>