private DataSet CreateDataSource() { string strCon; strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("excel.xls") + "; Extended Properties=Excel 8.0;"; OleDbConnection olecon = new OleDbConnection(strCon); OleDbDataAdapter myda = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", strCon); DataSet myds = new DataSet(); myda.Fill(myds); return myds; } protected void Button1_Click(object sender, EventArgs e) { GridView1.DataSource = CreateDataSource(); GridView1.DataBind(); }
为大家附3个精彩的专题:
以上就是关于asp.net中gridview控件的多种使用方法,很全面,目的就是想让亲们玩转gridview控件,希望大家喜欢小编整理的这两篇文章。
您可能感兴趣的文章: