Click here to Skip to main content
12,698,476 members (24,199 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# C#4.0
Hello Team ,

I imported excel data to gridview successfully, but i need the excel rowheader as gridview rowheader with out doing a loop, as my excel having more than 60,000 records, looping will be very slow,

my code is


string connectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source='"+ System.IO.Path.GetDirectoryName(path) + "';Extended Properties=\"Text;HDR=YES;FMT=Delimited\";";// "//Excel 8.0;";

DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.OleDb");

DbDataAdapter adapter = factory.CreateDataAdapter();

DbCommand selectCommand = factory.CreateCommand();
selectCommand.CommandText = "select * from [" + System.IO.Path.GetFileName(path) + "]";

DbConnection connection = factory.CreateConnection();
connection.ConnectionString = connectionString;

selectCommand.Connection = connection;

adapter.SelectCommand = selectCommand;

adapter.Fill(data);

Gridview.DataSource = data.Tables[0];

The above code is importing the all the fields of excel, but i need the excel rowID column

i mean row header, which is the identity column in excel, the first column

can any one helps me
Posted 17-Jan-13 23:14pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100