跪求大家帮这段代码,终身感激不尽,谢谢了
public partial class main : System.Web.UI.Page
{
public void Page_Load(object sender, EventArgs e)
{
Label1.Text = ("欢迎供应商" + Session["name"].ToString() + "登陆富基V3。2供应商查询系统");
//Session.Remove("name");
TextBox1.Text = Session["name"].ToString();
OracleConnection conn = DB.createConnection();
conn.Open();
OracleCommand cmd = new OracleCommand("select gys,jyfs,gz,rq from jxc_gz_day where gys='" + TextBox1.Text + "'", conn);
OracleDataReader str = cmd.ExecuteReader();
this.GridView1.DataSource = str;
this.GridView1.DataBind();
str.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
这段代码打开以后,SQL语句里面的数据就直接在页面上显示了。这不是我要的结果,我要在页面打开的时候数据不显示,在点了Button1按钮的时候才显示出来,应该怎么改动一下,请大家帮个忙,终身感激。
--------------------编程问答-------------------- 谢谢大家了,我已经弄好了 --------------------编程问答-------------------- //aspx文件Button1一定要注册OnClick事件
public partial class main : System.Web.UI.Page
{
public void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = ("欢迎供应商" + Session["name"].ToString() + "登陆富基V3。2供应商查询系统");
//Session.Remove("name");
TextBox1.Text = Session["name"].ToString();
OracleConnection conn = DB.createConnection();
conn.Open();
OracleCommand cmd = new OracleCommand("select gys,jyfs,gz,rq from jxc_gz_day where gys='" + TextBox1.Text + "'", conn);
OracleDataReader str = cmd.ExecuteReader();
this.GridView1.DataSource = str;
this.GridView1.DataBind();
str.Close();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
--------------------编程问答-------------------- 你把Load的写在按钮事件里就OK 了啊 --------------------编程问答-------------------- 你把Load的写在按钮事件里就OK 了啊 --------------------编程问答-------------------- 那么快,真后悔没有早点来啊
我被楼主的标题吸引了,可是却没有帮到楼主,真是苍天无眼啊
不过既然楼主已经把问题解决了,那我也宽心了,呵呵 .
补充:.NET技术 , ASP.NET