DropDownList1實現傳值再DataGuid中
来源:互联网 发布:ionic2 node sass 编辑:程序博客网 时间:2024/05/17 22:51
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
DataTable dtList=new DataTable();
dtList=GetQuery(DropDownList1.SelectedIndex);
this.DataGrid1.DataSource=dtList.DefaultView;
this.DataGrid1.DataBind();
}
}
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
DataTable dtList=new DataTable();
dtList=GetQuery(DropDownList1.SelectedIndex);
this.DataGrid1.DataSource=dtList.DefaultView;
this.DataGrid1.DataBind();
}
private DataTable GetQuery(int SelectIndex)
{
string strCmdText="";
SqlConnection conn =new SqlConnection();
DataSet ds = new DataSet();
DataTable dtResult = new DataTable("QueryDateTime");
ds.Tables.Add("QueryDateTime");
switch(SelectIndex)
{
case 0:
strCmdText="select staff_name as 姓名,staff_sex as 性別,staff_native as 籍貫,staff_diploma as 學歷,staff_ismarry as 婚否 ,staff_birthday as 出生年月 ,staff_identitycard as 證件號碼,staff_skill as 特長,staff_old_dept as 原單位,staff_old_leavedate as 離職時間,staff_rapport as 關係,introducer_dept as 介紹人部門,introducer_name as 介紹人姓名,introducer_indate as 入廠時間 from Staff_Register ";
conn=DBC.CreateDB();
break;
case 1:
strCmdText="select staff_name as 姓名,staff_sex as 性別,staff_native as 籍貫,staff_diploma as 學歷,staff_ismarry as 婚否 ,staff_birthday as 出生年月 ,staff_identitycard as 證件號碼,staff_skill as 特長,staff_old_dept as 原單位,staff_old_leavedate as 離職時間,staff_rapport as 關係,introducer_dept as 介紹人部門,introducer_name as 介紹人姓名,introducer_indate as 入廠時間 from Staff_Register where staff_identitycard not in (select staff_identitycard from Staff_Register where staff_identitycard in (select id_no from [it-srv-db1].fc_person_data.dbo.trans_staff where status>0)) and staff_identitycard not in (select staff_identitycard from [it-srv-db1].fc_person_data.dbo.trans_staff Where out_date Is Not Null And out_date<>'' Or datediff(dd,in_date,getdate())<30) and staff_identitycard not in (select staff_identitycard from Staff_Register A, (select department_no,staff_name,introducer_remark,in_date from [it-srv-db1].fc_person_data.dbo.trans_staff where datediff(dd,in_date,getdate())<30 ) B Where A.introducer_name=B.staff_name) and staff_identitycard not in (select staff_identitycard from Staff_Register where datediff(yy,staff_birthday,getdate())<18 Or datediff(yy,staff_birthday,getdate())>35)";
conn=DBC.CreateDB();
break;
case 2:
strCmdText="select staff_name as 姓名,staff_identitycard as 身份證號碼 from Staff_Register where staff_identitycard in (select id_no from [it-srv-db1].fc_person_data.dbo.trans_staff where status>0) ";
conn=DBC.CreateDB();
break;
case 3:
strCmdText="select A.staff_name as 姓名,staff_sex as 性別,staff_native as 籍貫,B.out_date as 出廠日期 from Staff_Register A Inner Join [it-srv-db1].fc_person_data.dbo.trans_staff B On A.staff_identitycard=B.id_no And (B.id_no is null Or datediff(dd,B.out_date,getdate())<30)";
conn=DBC.CreateDB();
break;
case 4:
strCmdText="select A.staff_name as 姓名 ,B.staff_name as 介紹人姓名 ,B.department_no as 介紹人部門,B.introducer_remark as 介紹人關係,B.in_date as 入敞時間 from Staff_Register A, (select department_no,staff_name,introducer_remark,in_date from [it-srv-db1].fc_person_data.dbo.trans_staff where datediff(dd,in_date,getdate())<30 ) B Where A.introducer_name=B.staff_name ";
conn=DBC.CreateDB();
break;
case 5:
strCmdText="select staff_name as 姓名,staff_birthday as 出生年月 from Staff_Register where datediff(yy,staff_birthday,getdate())<18 Or datediff(yy,staff_birthday,getdate())>35 order by staff_birthday desc";
conn=DBC.CreateDB();
break;
}
SqlDataAdapter sqlDA = new SqlDataAdapter(strCmdText,conn);
sqlDA.Fill(ds,"QueryDateTime");
dtResult=ds.Tables[0];
return dtResult;
}
private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
this.DataGrid1.CurrentPageIndex=e.NewPageIndex;
}
- DropDownList1實現傳值再DataGuid中
- DropDownList1實現傳值再DataGuid中
- asp.net中this.DropDownList1.SelectedIndex > -1这句话是什么意思
- “DropDownList1”有一个无效 SelectedValue,因为它不在项目列表中。
- "DropDownList1“有一个无效 SelectedValue,因为它不在项目列表中。
- System.ArgumentOutOfRangeException: “DropDownList1”有一个无效 SelectedValue,因为它不在项目列表中
- “DropDownList1”有一个无效 SelectedIndex,因为它不在项目列表中。
- DropDownList1.SelectedIndex及DropDownList1.SelectedValue的赋值
- dataGuid數據綁定及其分頁
- dataGuid數據綁定及其分頁
- easyui dataguid subgrid 子表
- DetailsView使用DropDownList1
- 关于DetailsView使用DropDownList1!
- 关于GridView,DetailsView,DropDownList1
- DropDownList1 各种属性
- DropDownList1.Items.Insert 与 DropDownList1.Items.Add 的区别
- DropDownList1对数据库的操作
- 数据库向DropDownList1绑定数据
- net上傳代碼
- LOTUS学习技巧 三
- dataGuid數據綁定及其分頁
- 連接方法
- botton插入數據
- DropDownList1實現傳值再DataGuid中
- 水晶報表的綁定
- (爆笑)国产电视剧的电脑高手
- Microsoft Access 名字的由来(Where did the name for Microsoft Access come from?)
- png 文档格式
- 人与软件
- 苏格拉底
- 在Repeater中嵌套使用Repeater
- 图像文件后缀一览表