This is a migrated thread and some comments may be shown as answers.

Import CSV to radGrid

1 Answer 216 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Suriya
Top achievements
Rank 1
Suriya asked on 06 Apr 2010, 07:27 AM
Dear Sir,
               Now i am need to import a csv file's data, into the radgrid... please help for this query.,

then another one is, i wanna to import the field name in the radgrid's column one by one.,

reply both the queries...

Regards

S Suriya Narayanan

1 Answer, 1 is accepted

Sort by
0
Jim
Top achievements
Rank 1
answered on 08 Apr 2010, 11:18 PM
That is not possible, you have to do something like:

        string strConnectionString = string.Empty;  
        strConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strFilePath + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";";  
        OleDbConnection cnCSV = new OleDbConnection(strConnectionString);  
        cnCSV.Open();  
        OleDbCommand cmdSelect = new OleDbCommand(@"SELECT [Number], [Transaction Number], [Client], [Amount], [Note] FROM [Sheet1$] WHERE [Number] IS NOT NULL", cnCSV);  
        OleDbDataAdapter daCSV = new OleDbDataAdapter();  
        daCSV.SelectCommand = cmdSelect;  
        DataTable dtCSV = new DataTable();  
        daCSV.Fill(dtCSV);  
        cnCSV.Close();  
        daCSV = null;  
        return dtCSV;  
 
and then bind the datatable to the grid. I am pretty sure there are other posts about this.
Tags
Grid
Asked by
Suriya
Top achievements
Rank 1
Answers by
Jim
Top achievements
Rank 1
Share this question
or