大家好,我是个新手,才接触.NET3个月,请大家多指教
我的问题是提示错误:上下文中不存在fileupload
源代码是:
public partial class _Default : System.Web.UI.Page
{
string strconn;
OracleConnection cn; protected void Page_Load(object sender, EventArgs e)
{
strconn = ConfigurationManager.ConnectionStrings["Connection String"].ToString();
cn = new OracleConnection(strconn);
} protected void Button1_Click(object sender, EventArgs e)
{
string type1 = FileUpload1.[/color]PostedFile.FileName;
string type = type1.Substring(type1.LastIndexOf(".") + 1);
//string dbName = Path.GetFileName(FileUpload1.FileName).Replace(".xls", "");
if (string.Equals(type, "xls"))
{
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + type1 + ";Extended Properties='Excel 8.0;IMEX=1'";
System.Data.OleDb.OleDbConnection Conn = new System.Data.OleDb.OleDbConnection(strCon);
string strCom = "SELECT * FROM [Sheet1$]";
DataSet ds = new DataSet();
Conn.Open();
System.Data.OleDb.OleDbDataAdapter myCommand = new System.Data.OleDb.OleDbDataAdapter(strCom, Conn);
myCommand.Fill(ds, "[Sheet1$]");
Conn.Close();
if (ds != null)
{
GridView1.DataSource = ds;
GridView1.DataBind();
Session["a"] = ds;
//File.Delete(newName);
Button2.Visible = true;
}
}
else
{
this.Page.Response.Write("<script>alert('文件格式不正确')</script>");
}
}
我的问题是提示错误:上下文中不存在fileupload
源代码是:
public partial class _Default : System.Web.UI.Page
{
string strconn;
OracleConnection cn; protected void Page_Load(object sender, EventArgs e)
{
strconn = ConfigurationManager.ConnectionStrings["Connection String"].ToString();
cn = new OracleConnection(strconn);
} protected void Button1_Click(object sender, EventArgs e)
{
string type1 = FileUpload1.[/color]PostedFile.FileName;
string type = type1.Substring(type1.LastIndexOf(".") + 1);
//string dbName = Path.GetFileName(FileUpload1.FileName).Replace(".xls", "");
if (string.Equals(type, "xls"))
{
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + type1 + ";Extended Properties='Excel 8.0;IMEX=1'";
System.Data.OleDb.OleDbConnection Conn = new System.Data.OleDb.OleDbConnection(strCon);
string strCom = "SELECT * FROM [Sheet1$]";
DataSet ds = new DataSet();
Conn.Open();
System.Data.OleDb.OleDbDataAdapter myCommand = new System.Data.OleDb.OleDbDataAdapter(strCom, Conn);
myCommand.Fill(ds, "[Sheet1$]");
Conn.Close();
if (ds != null)
{
GridView1.DataSource = ds;
GridView1.DataBind();
Session["a"] = ds;
//File.Delete(newName);
Button2.Visible = true;
}
}
else
{
this.Page.Response.Write("<script>alert('文件格式不正确')</script>");
}
}
解决方案 »
- 求一个gridview模板中控件相互传值的问题。
- asp.net设计中的一张球队训练表,帮我看看哪里错了?
- 急~~~ !!我想在网页中加一个 下载插件的连接,应该怎么加呢
- 求在Asp.net 1.1中使用MemberRole组件方面的相关资料,已经baidu,google过了,未果。
- 验证控件不起作用!!!怪事!
- 让高手帮写一个简单的系统.热心人帮帮忙.
- 初学ASP。NET,有点问题,请指教!
- 繁体版操作系统与简体版系统
- 梅子的树,在ASP.NET里的VB.NET环境里怎么实现的?找遍互联网,没有答案!期待高手协助ing
- 数据库检索出来的时间与当前时间相比较,以不同的颜色显示在dbgrid中
- 关于数据查询问题
- .net 如何调用http接口
string type1 = FileUpload1.[/color]PostedFile.FileName;
中提示错误,请指教
检查控件ID
aspx页面代码应该没那个控件