Azure csv radgrid dataset bind attempt

1 posts, 0 answers
  1. John
    John avatar
    4 posts
    Member since:
    Aug 2015

    Posted 10 Feb 2018 Link to this post

    I am attempting to download a csv file from Azure container blob, read and load it to a dataset and then bind it to the radgrid.  

    I can download the data and set it to a string (the sample data is listed below) but not sure how to load it to the dataset. 

    When I load the data to a stream and then try to load it to a dataset, I received the following error: "Data at the root level is invalid. Line 1, position 1."

    Here is a sample of the Data that is in the file ( I also tried it with no hdr record, same results...)

    DeptCode,DeptName,AccountCode,Description,Qty,Expense
    1001,Presidents,6220,FT Senior Administrator,1,126000
    1001,Presidents,6221,FT Professional Staff,1,105050
    1001,Presidents,6300,FT Administrative,1,60000
    1001,Presidents,6425,FT Technical/Paraprofessional,1,70000
    1001,Presidents,6426,PT Technical/Paraprofessional,1,32000

    Here is my source code....

                        // Retrieve storage account from connection string.
                        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
                        // Create the blob client.
                        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
                        // Retrieve reference to a previously created container.
                        CloudBlobContainer container = blobClient.GetContainerReference("hsc2");
                        // Retrieve reference to a blob named "myblob".
                        CloudBlockBlob blockBlob = container.GetBlockBlobReference(FileUpload1.FileName); 
                        //...Create or overwrite the "myblob" blob with contents from a local file.
                        using (var memoryStream = new MemoryStream())
                        {
                            blockBlob.DownloadToStream(memoryStream);
                            memoryStream.Position = 0;
                            StreamReader streamReader = new StreamReader(memoryStream);
                            //String blobText = streamReader.ReadToEnd();
                            DataSet ds1 = new DataSet();
                            ds1.ReadXml(streamReader);

                            RadGrid1.DataSource = ds1;

                            RadGrid1.DataBind();

                            RadGrid1.Rebind();
                         }


Back to Top