📄 opttable.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using gyit.Data;
using System.Xml;
using System.Configuration;
namespace itcrm.dialog
{
/// <summary>
/// OptArea 的摘要说明。
/// </summary>
public class OptTable : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.TextBox txtReturn;
public DBOperator db;
private void Page_Load(object sender, System.EventArgs e)
{
db = DBOperator.CreateObject((string)ConfigurationSettings.AppSettings["DSN"]);
string tempStr=Page.Request["id"].Replace("'","");
if (!Page.IsPostBack)
datashow(tempStr);
//cmdOK.Attributes.Add("onclick","javascript:sendTo();");
//onclick="javascript:sendTo();"
// 在此处放置用户代码以初始化页面
}
public void datashow(string who)
{
string strSQL="";
string strKey="";
switch(who)
{
case "optdq"://区域选择
strSQL ="select dq_ID as '地区编号' ,dq_Name as '地区名称' from tb_dq";
strKey="地区编号";
break;
case "opthy_ID"://节点选择
strSQL ="select hy_ID as '行业编号' ,hy_Name as '行业名称' from tb_hy ";
strKey="行业编号";
break;
case "optbz_ID"://节点类型
strSQL ="select bz_ID as '标准编号' ,BM as '标准名称' from tb_gwrbz ";
strKey="标准编号";
break;
case "optNode"://节点选择
strSQL ="select NodeID as '节点ID' ,NodeName as '节点名称' from SysMenu ";
strKey="节点ID";
break;
case "optNodeType"://节点类型
strSQL ="select NodeID as '节点类型ID' ,NodeName as '节点类型名称' from SysMenu where ParentID ='0'";
strKey="节点类型ID";
break;
default:
strSQL ="select dq_ID as '地区编号' ,dq_Name as '地区名称' from tb_dq ";
strKey="地区编号";
break;
}
if (strKey!="")
{
DataGrid1.DataKeyField=strKey;
db.Open();
Session["DS"]=db.exeSqlForDataSet(strSQL);
Session["strKey"]=strKey;
DataGrid1.DataSource=Session["DS"];
DataGrid1.DataBind();
db.Close();
}
}
public void selData(object sender, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName=="Select")
txtReturn.Text=DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
DataGrid1.DataKeyField=Session["strKey"].ToString();
DataGrid1.CurrentPageIndex =e.NewPageIndex;
DataGrid1.DataSource=Session["DS"];
DataGrid1.DataBind();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -