<% @ Page language = "c #" debug = "true"%>
<% @ Import namespace = "system.data"%>
<% @ Import namespace = "system.data.oledb"%>
Private Dataset CreateDataSource () {
String strconn;
StrConn = "provider = microsoft.jet.Oledb.4.0;"
"Data Source = C: //inetpub//wwwroot//contacts.xls;"
"Extended Properties = Excel 8.0;";
OLEDBCONNECTION CONN = New OLEDBCONNECTION (STRCONN);
OLEDBDataAdapter mycommand = new oledbdataadapter ("Select * from [contactList $], strconn);
Dataset mydataset = new dataset ();
Mycommand.fill (MyDataSet);
Return mydataset;
}
Public void Page_load (Object Sender, Eventargs E) {
IF (! ispostback) {
MyGrid.datasource = createdataSource ();
MyGrid.databind ();
}
}
script>