Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a gridview which has 4 columns in total now the first column name i am importing from an excel sheet which is named as "FileName".the gridview is taking columnheader as F1 instead of filename.i need that f1 to be replaced with my column header name.


What I have tried:

so far i have tried 

                         dataGridView1.Columns[0].Name = "Filename";
                      
                       dtExcel.Columns.Add("Filename");
                    
                    dataGridView1.Columns[0].HeaderText = "Filename"
                    
                    by this all new column of filename is getting added but that F1 is not getting replaced.
                   
                    
                    Help Please.
Posted
Updated 14-Feb-17 23:53pm
v3
Comments
Ralf Meier 15-Feb-17 2:48am    
I'm sorry ... but with this Information I could not help you - please improve your question with more Information ...
NazneenSayed 15-Feb-17 2:54am    
can we attach image here ? i could not find and i think this question will better be understood with that image
Ralf Meier 15-Feb-17 2:57am    
I'm not sure if this really helps - but you could try ...
NazneenSayed 15-Feb-17 3:01am    
done.please check
Ralf Meier 15-Feb-17 3:06am    
I don't see anything ...

1 solution

resolved this myself just needed to change the Query from
select * from [Sheet$] to select F1 as Filename from [Sheet$]

thanks for the help guys.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900