使用session在不同页面之间传递参数,sqldatasource按条件查询
来源:互联网 发布:浙江政务服务软件 编辑:程序博客网 时间:2024/05/22 12:46
1.如图1 所示用户设置预警参数,通过session将textbox输入的参数传入另一个页面,如图2所示:
图1
2.图1的后台代码如下:
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace WebApplication1{ public partial class WebForm19 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Session["Temp1"] = TextBox1.Text; Session["Temp2"] = TextBox2.Text; Session["Humid1"] = TextBox3.Text; Session["Humid2"] = TextBox4.Text; Session["Deform1"] = TextBox5.Text; Session["Deform2"] = TextBox6.Text; } protected void TextBox1_TextChanged(object sender, EventArgs e) { } protected void Button4_Click(object sender, EventArgs e) { Session["Temp1"] = TextBox1.Text; Session["Temp2"] = TextBox2.Text; Session["Humid1"] = TextBox3.Text; Session["Humid2"] = TextBox4.Text; Session["Deform1"] = TextBox5.Text; Session["Deform2"] = TextBox6.Text; } }}3.如图2所示,左侧显示图1传入的预警参数,右侧通过添加数据源,选择查询的范围(在预警参数范围内),病通过Gridview控件显示在表格中
图2
4.图2的后台代码如下所示:
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Windows.Forms;using System.Windows.Forms.DataVisualization.Charting;using System.Data;using System.Data.SqlClient;namespace WebApplication1{ public partial class WebForm15 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //若管理员不设置预警参数,使用系统默认预警参数 if (Session["Temp1"] == null || Session["Temp2"] == null || Session["Humid1"] == null || Session["Humid2"] == null || Session["Deform1"] == null || Session["Deform2"] == null) { Label3.Text = Convert.ToString(15); Label4.Text = Convert.ToString(25); Label5.Text = Convert.ToString(40); Label6.Text = Convert.ToString(60); Label7.Text = Convert.ToString(4); Label8.Text = Convert.ToString(9); } else { //显示WarningParameter1.aspx设置的预警参数 Label3.Text = Session["Temp1"].ToString(); Label4.Text = Session["Temp2"].ToString(); Label5.Text = Session["Humid1"].ToString(); Label6.Text = Session["Humid2"].ToString(); Label7.Text = Session["Deform1"].ToString(); Label8.Text = Session["Deform2"].ToString(); //根据预警参数筛选异常数据 } } protected void GridView2_SelectedIndexChanged(object sender, EventArgs e) { } }}
5.sqldatasource按条件查询
在Gridview点击新建数据源,选择数据库,选择数据表,选择数据列,添加where语句
0 0
- 使用session在不同页面之间传递参数,sqldatasource按条件查询
- 在不同页面之间传递参数
- 使用session在页面间传递参数
- 在不同的页面之间用javascript传递参数
- 使用session在jsp页面之间传递多维数组
- 两个不同HTML页面之间参数传递
- Flask在不同页面间传递参数
- 使用 SqlDataSource 进行带参数的查询
- 不同页面之间实现参数传递的几种方式
- cookie,request,session与application页面之间参数的传递
- 参数传递 - 刷新页面后保留查询条件
- 页面之间传递参数.
- 页面之间传递参数
- 页面之间传递参数
- 不同页面之间传递值
- [Classic ASP]实现session在页面之间的传递
- scrapy 在不同的Request之间传递参数的办法
- Scrapy抓取在不同级别Request之间传递参数
- 条款07:为多态基类声明virtual析构函数
- IOS网络编程:HTTP
- mysql 不能启动 并 没有报错 原因
- 构建一个二叉堆实例
- 谈谈Fragment的构造函数、重新创建(recreate)及相关
- 使用session在不同页面之间传递参数,sqldatasource按条件查询
- PEM_密钥对生成与读取方法
- 初开技术博客
- 【POJ 3666】Making the Grade(简单DP)
- win8.1、win10系统修改窗口背景颜色为健康的护眼颜色
- 对于begin和end的认识
- Android4.0 Launcher源码研究
- 【AJAX02】AJAX实战
- 在VS2013中配置Opengl