Create reportviewer from dataset
<p>I am reading a file from which I create a dataset and I need to create a report from that dataset but this code is not working. so maybe someone could tell me what I am doing wrong I would really apreciated it or suggest another approach to this issue.</p>

<p>The BuildataSet function is working properly, creating the report its whats giving me problems.</p>

<pre><code>public DataSet BuildDataSet(string file,string tableName,string delimeter)
{
  //create our DataSet
  DataSet domains = new DataSet();
   //add our table
   domains.Tables.Add(tableName);
    String c =    "VOYAGE|SAILDATE|DELIVERYDATE|AMENITY|QTY|COMPLIMENTS|MESSAGE|CABIN|1STPAXNAME|"
    +"1STPAXLAST|2NDPAXNAME|2NDPAXLAST|3RDPAXNAME|3RDPAXLAST|4THPAXNAME|4THPAXLAST|SHIP|TYPE|DELIVERYTYPE|DROOM|SEATING|TABLE|GHOSTCOLUMN";

try
{
    //first make sure the file exists
    if (File.Exists(file))
    {
        //create a StreamReader and open our text file
        StreamReader reader = new StreamReader(file);

        //read the first line in and split it into columns
        string [] columns = c.Split('|');
        //now add our columns (we will check to make sure the column doesnt exist before adding it)
        foreach (string col in columns)
        {
            //variable to determine if a column has been added
            bool added = false;
            string next = "";
            //our counter
            int i = 0;
            while (!(added))
            {
                string columnName = col;


                    //now check to see if the column already exists in our DataTable
                    if (!(domains.Tables[tableName].Columns.Contains(columnName)))
                    {
                        //since its not in our DataSet we will add it
                        domains.Tables[tableName].Columns.Add(columnName, typeof(string));
                        added = true;
                    }//end if
                    else
                    {
                        //we didnt add the column so increment out counter

                        i++;
                        next = "_" + i.ToString();
                        break;
                    }//end else


             }
        }
        //now we need to read the rest of the text file
        string data = reader.ReadToEnd();

        //now we will split the file on the carriage return/line feed
        //and toss it into a string array
        string [] rows = data.Split("\r".ToCharArray());
        //now we will add the rows to our DataTable
        foreach (string r in rows)
        {
            string[] items = r.Split(delimeter.ToCharArray());
            //split the row at the delimiter
            //for (int i = 0; i &lt;= items.Count() - 1; i++)
            //{

                domains.Tables[tableName].Rows.Add(items);

            //}
        }
    }
    else
    {
        throw new FileNotFoundException("The file " + file + " could not be found");
    }

}
catch (FileNotFoundException ex)
{
    _message = ex.Message;
    return null;
}
catch (Exception ex)
{
    _message = ex.Message;
    return null;
}

//now return the DataSet
 return domains;
</code></pre>

<p>}
     //#endregion</p>

<pre><code>   protected void Button1_Click(object sender, EventArgs e)
{



    DataSet ds = BuildDataSet(@"C:/Documents/GIFTCDS.TXT", "MyNewTable", "|");
    GridView1.DataSource = ds;
    GridView1.DataBind();


    ReportDataSource rds = new ReportDataSource("MyNewTable", ds.Tables[0]);
    ReportViewer1.LocalReport.DataSources.Clear();
    ReportViewer1.LocalReport.DataSources.Add(rds);
    ReportViewer1.DataBind();
    ReportViewer1.LocalReport.Refresh();


}
</code></pre>
