* IBM to offer mobile security as a service IBM will start delivering mobile security-as-a-service (MaaS) through its own cloud infrastructure in India, a move that is expected to better address in-country data requirements... IBM Spectrum Computing: IBM has enlarged its portfolio of software-defined infrastructure solutions with cognitive features for workload management.  * LiFi internet technology has been introduced, the new type of wireless internet connection that gives 100 times faster than traditional WiFi -- Invented by Professor Harald Haas from the University of Edinburgh. * Sci. Rachid Yazami has developed a smart chip that charges smartphones in less than 10 minutes. BenQ has launched BlueCore projector - Consumer electronics major BenQ has launched its first BlueCore laser light source projector. For those unaware, devices with BlueCore laser technology have a high contrast output of 80000:1 with an extended lamp life and efficiency. *** 
  Oct 5 2018 12:09PM     Michael
  1 Comments    6405 Views  
Here Michael provided a short description with example for binding gridview from CSV file.
Here simple example for bind Gridview from CSV file. 

CSV File: 

HTML Code:

Copy the HTML code and paste it in your design page.

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">  
            The Developer Tips - Beyond the Knowledge
        <hr >
        <h4>CSV File to Gridview</h4>
                    Select File  
                    <asp:FileUpload ID="FileUpload1" runat="server" />  
                    <asp:Button ID="btnFileUpload" runat="server" Text="Upload" OnClick="btnFileUpload_Click" />  
            <asp:Label ID="lblError" runat="server" style="color:Red"></asp:Label>
        <br >  
        <br >  
        <asp:GridView ID="grdCSV" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">  
            <AlternatingRowStyle BackColor="White" />  
            <EditRowStyle BackColor="#7C6357" />  
            <FooterStyle BackColor="#1C5E66" Font-Bold="True" ForeColor="White" />  
            <HeaderStyle BackColor="#1C5E66" Font-Bold="True" ForeColor="White" />  
            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />  
            <RowStyle BackColor="#E3EAEB" />  
            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />  
            <SortedAscendingCellStyle BackColor="#F8FAFA" />  
            <SortedAscendingHeaderStyle BackColor="#246B61" />  
            <SortedDescendingCellStyle BackColor="#D4DFE1" />  
            <SortedDescendingHeaderStyle BackColor="#15524A" />  


using System.Data;
using System.IO;

C# Code:

Method for Page Load Event

protected void Page_Load(object sender, EventArgs e)
       lblError.Visible = false;

Method for File Upload Button

protected void btnFileUpload_Click_Click(object sender, EventArgs e)

            //Creating object of datatable  
            DataTable dtTblcsv = new DataTable();

                //creating columns in datatable

                //getting full file path of Uploaded file  
                string CSVFilePath = Server.MapPath(FileUpload1.PostedFile.FileName);

                //Reading All text  
                string ReadCSV = File.ReadAllText(CSVFilePath);

                //spliting row after new line  
                foreach (string csvRow in ReadCSV.Split('\n'))
                    if (!string.IsNullOrEmpty(csvRow))
                        //Adding each row into datatable  
                        int count = 0;
                        foreach (string FileRec in csvRow.Split(','))
                            dtTblcsv.Rows[dtTblcsv.Rows.Count - 1][count] = FileRec;

                    //Calling Bind Grid Functions  

            catch (Exception ex)
                lblError.Visible = true;
                lblError.Text = ex.Message.ToString();

Method for Bind Gridview

private void Bind_Gridview(DataTable csvdt)
                grdCSV.DataSource = csvdt;
            catch (Exception ex)
                lblError.Visible = true;
                lblError.Text = ex.Message.ToString();


 I hope it will helps. Thanks.


Adam Fletcher
Nov 11 2018 9:38AM
One can also try to know more about how to generate Excel files on C#.

Recent Posts
Create Amazon ElasticCache Using Memcached in CSharp
Oct 29 2018 12:09PM Posted By Amose
Get Google Map Lat Lng (Geo Point) By Pincode in C#
Oct 28 2018 12:09PM Posted By Pranav
Google URL Shortener in C#
Oct 20 2018 12:09PM Posted By Sanjay
Bind Gridview from CSV file in Asp.Net C#
Oct 5 2018 12:09PM Posted By Michael
Call WebService method from jQuery in every 1 minute
Sep 26 2018 12:09PM Posted By John
Gridview custom CSS in ASP.Net
Sep 14 2018 12:09PM Posted By Micheal Ryan
Read excel file and bind to Gridview in C#
Sep 10 2018 12:09PM Posted By Micheal
Follow us on Facebook
Follow us on Google +
Recent post in your Email inbox.
Enter your email address: