Click here to Skip to main content
16,005,344 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionDetails view Insert buttion not working in Update panel Pin
Mr.Himansu22-Feb-09 23:19
Mr.Himansu22-Feb-09 23:19 
AnswerRe: Details view Insert buttion not working in Update panel Pin
Mr.Himansu24-Feb-09 1:59
Mr.Himansu24-Feb-09 1:59 
QuestionProblem in opening an uploaded site developed on ASP.NET Pin
heyitsgaurav22-Feb-09 23:12
heyitsgaurav22-Feb-09 23:12 
AnswerRe: Problem in opening an uploaded site developed on ASP.NET Pin
Anurag Gandhi22-Feb-09 23:25
professionalAnurag Gandhi22-Feb-09 23:25 
GeneralRe: Problem in opening an uploaded site developed on ASP.NET Pin
heyitsgaurav23-Feb-09 0:28
heyitsgaurav23-Feb-09 0:28 
QuestionCreate mp3 output using sapi 5.1 in web applications(c#). Pin
vsmarimuthu22-Feb-09 23:04
vsmarimuthu22-Feb-09 23:04 
Questiondata tranfer in ASP.net(visual studio 2003,C#) Pin
Arpita2722-Feb-09 22:20
Arpita2722-Feb-09 22:20 
AnswerRe: data tranfer in ASP.net(visual studio 2003,C#) [modified] Pin
Greg Chelstowski22-Feb-09 22:38
Greg Chelstowski22-Feb-09 22:38 
First of all, if you want to show your Excel data in a datagridview on an aspx page, you have to upload that spreadsheet onto the server. Best way - use the FileUpload control.

I'm only going to show you one way of doing what you want to do. If you don't like it, at least you'll have some reference on how to approach it.

To "make the connection" with an excel spreadsheet, you need to add reference to Interop.Excel.dll, Interop.Microsoft.Office.Core.dll and Interop.VBIDE.dll in your project first.


Then, in your code:
using System.Data.OleDb;


private void ExcelToGrid()
{
DataTable dt = new DataTable("sheet");
OleDbConnection conn = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=" + MapPath("Yourfilename.xls";extended properties=Excel 8.0");
OleDbDataAdapter SheetAdapter = new OleDbDataAdapter("select * from [$Sheet1]", conn);
SheetAdapter.Fill(dt);
DataGridView1.DataSource = dt;
DataGridView1.DataBind();
}


That should really do the trick. Obviously, you need to change $Sheet1 to whatever your sheet is called in the spreadsheet. And read up on versions of the Jet engine - i can't guarantee it's gonna work with all the living versions of Excel.

var question = (_2b || !(_2b));

modified on Monday, February 23, 2009 7:05 AM

GeneralRe: data tranfer in ASP.net(visual studio 2003,C#) Pin
Anurag Gandhi22-Feb-09 23:34
professionalAnurag Gandhi22-Feb-09 23:34 
GeneralRe: data tranfer in ASP.net(visual studio 2003,C#) Pin
Greg Chelstowski23-Feb-09 1:04
Greg Chelstowski23-Feb-09 1:04 
GeneralRe: data tranfer in ASP.net(visual studio 2003,C#) Pin
Anurag Gandhi23-Feb-09 1:11
professionalAnurag Gandhi23-Feb-09 1:11 
AnswerRe: data tranfer in ASP.net(visual studio 2003,C#) Pin
Sneha Bisht23-Feb-09 2:57
Sneha Bisht23-Feb-09 2:57 
AnswerRe: data tranfer in ASP.net(visual studio 2003,C#) Pin
Arpita2723-Feb-09 20:06
Arpita2723-Feb-09 20:06 
GeneralRe: data tranfer in ASP.net(visual studio 2003,C#) Pin
Greg Chelstowski23-Feb-09 21:25
Greg Chelstowski23-Feb-09 21:25 
QuestionHow to make a context menu to JQGrid ? Pin
Denver Thomas22-Feb-09 22:07
Denver Thomas22-Feb-09 22:07 
AnswerRe: How to make a context menu to JQGrid ? Pin
lobbychmd22-Feb-09 22:44
lobbychmd22-Feb-09 22:44 
QuestionCreating a ASP.NET web site in a team for the first time Pin
Clifweb22-Feb-09 21:56
Clifweb22-Feb-09 21:56 
AnswerRe: Creating a ASP.NET web site in a team for the first time Pin
Christian Graus22-Feb-09 22:06
protectorChristian Graus22-Feb-09 22:06 
QuestionRe: Creating a ASP.NET web site in a team for the first time Pin
Clifweb22-Feb-09 22:15
Clifweb22-Feb-09 22:15 
AnswerRe: Creating a ASP.NET web site in a team for the first time Pin
Christian Graus23-Feb-09 8:51
protectorChristian Graus23-Feb-09 8:51 
QuestionEnterprise library 4.0 -Localized Validation message Pin
Shivaji Shitole22-Feb-09 21:39
Shivaji Shitole22-Feb-09 21:39 
QuestionThe type or namespace name 'ScriptManager' does not exist in the namespace 'System.Web.UI' Pin
Member 387988122-Feb-09 21:37
Member 387988122-Feb-09 21:37 
AnswerRe: The type or namespace name 'ScriptManager' does not exist in the namespace 'System.Web.UI' Pin
Christian Graus22-Feb-09 21:47
protectorChristian Graus22-Feb-09 21:47 
GeneralRe: The type or namespace name 'ScriptManager' does not exist in the namespace 'System.Web.UI' Pin
Member 387988122-Feb-09 22:06
Member 387988122-Feb-09 22:06 
AnswerRe: The type or namespace name 'ScriptManager' does not exist in the namespace 'System.Web.UI' Pin
adriancs8-Jul-14 18:54
mvaadriancs8-Jul-14 18:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.