Click here to Skip to main content
16,012,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i import only 5 row values from excel sheet in gridview. if the excel sheet contain more than 10 rows means only 5 row values should be displayed in gridview.. is it possible
Posted
Updated 4-Feb-11 23:46pm
v2

1 solution

See here[^].
 
Share this answer
 
Comments
gowdhami 5-Feb-11 5:55am    
thanks for your answer but i have to import only 5 rows not all values in excelsheet..
Martin Arapovic 5-Feb-11 6:19am    
I can see two solutions for this:
1. You can add TOP 5 to oledb command and get only first 5 rows.
2. When you return data set with one table from excel sheet using example that Abhinav posted, you can select desired number of records using LINQ;
Example 1: "DataTable".AsEnumerable().Take(5);
Example 2: "DataTable".Rows.Cast<datarow>().Take(n);

This is only example and maybe there is syntax error, but I think you will understand what I'm talking about.

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