Thread: How do I read a CSV into a HTML Table?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Slime Dragoon_42's Avatar
    Join Date
    Feb 2003
    Location
    Vancouver
    Posts
    90

    Question 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:
    <&#37;@ 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>
    Last edited by Dragoon_42; 01-29-2008 at 02:47 PM. Reason: solved

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Group Project Help/Volunteer
    By DarkDot in forum C++ Programming
    Replies: 3
    Last Post: 04-24-2007, 11:36 PM
  2. html read
    By Ron in forum C Programming
    Replies: 8
    Last Post: 06-12-2006, 05:24 PM
  3. MUD Concept Question
    By mrpickle in forum Game Programming
    Replies: 3
    Last Post: 12-01-2003, 12:45 PM
  4. how to read csv file ?
    By kosong in forum C Programming
    Replies: 5
    Last Post: 11-13-2003, 08:14 PM
  5. progarm doesnt compile
    By kashifk in forum Linux Programming
    Replies: 2
    Last Post: 10-25-2003, 05:54 PM