哪位大虾给我看下,我这是列表页的后台代码.其中有一个根据名称和NUM的模糊查询.还有一个下拉框的查询.现在模糊查询用名称查查不出来,但是用NUM就可以查出来.下拉框选择了也查不出来..哪位大虾知道的给我改下..如果需要前台代码也请说明一下.我贴出来..
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 KYCMS.LAN;
using KYCMS.COMMA;
using KYCMS.BLL;
namespace KYCMS.WEB.kyzmanage.zongmanage
{
/// <summary>
/// manage_area_list 的摘要说明。
/// </summary>
public class manage_area_list : System.Web.UI.Page
{
string manageloginname;
int managegroupid;
string AMLogin_name;
string AMLogin_password;
string reacright;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Confirm,upflag,upflag2;
protected System.Web.UI.WebControls.Repeater Repeater1;
protected System.Web.UI.WebControls.TextBox kyword;
protected System.Web.UI.WebControls.DropDownList alldepid,alldepid2,alldepid3,alldepid4;
public string stringwhere,stringwhere2,mysearch_c,newskey1="",newskey2="",newskey3="",pagelinkstr;
public int intPageNo,intPageSize=20,intPageCount,RecordCount=0;
public int CurPage,mytotalpages,myonepages,totalrec;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Button up1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
string jsScript = "<script language=JavaScript> \n" +
"<!--\n" +
"function confirmDelete (frm) {\n\n" +
" // loop through all elements\n" +
" for (i=0; i<frm.length; i++) {\n\n" +
" // Look for our checkboxes only\n" +
" if (frm.elements[i].name.indexOf ('DeleteThis') !=-1) {\n" +
" // If any are checked then confirm alert, otherwise nothing happens\n" +
" if(frm.elements[i].checked) {\n" +
" return confirm (' "+ LAN.R2.GetString("ty_delete") +" ?')\n" +
" }\n" +
" }\n" +
" }\n" +
"}\n\n\n" + "function select_deselectAll (chkVal, idVal) {\n" +
"var frm = document.forms[0];\n" +
"// loop through all elements\n" +
" for (i=0; i<frm.length; i++) {\n" +
" // // Look for our Header Template's Checkbox\n" +
" if (idVal.indexOf ('CheckAll') != -1) {\n" +
" // Check if main checkbox is checked, then select or deselect datagrid checkboxes \n" +
" if(chkVal == true) {\n" +
" frm.elements[i].checked = true;\n" +
" } else {\n" +
" frm.elements[i].checked = false;\n" +
" }\n" +
" // Work here with the Item Template's multiple checkboxes\n" +
" } else if (idVal.indexOf('DeleteThis') != -1) {\n" +
" // Check if any of the checkboxes are not checked, and then uncheck top select all checkbox\n" +
" if(frm.elements[i].checked == false) {\n" +
" frm.elements[1].checked = false; // Check if any of the checkboxes are not checked, and then uncheck top select all checkbox\n" +
" }\n" +
" }\n" +
" }\n" +
"}" +
"//--> \n" +
"</script>"; //Allows our .NET page to add client-side script blocks when page loads, instead of the conventional HTML JS tags.
RegisterClientScriptBlock ("clientScript", jsScript);
WebControl button = (WebControl) Page.FindControl ("Confirm");
button.Attributes.Add ("onclick", "return confirmDelete (this.form);");
BLL.adminCheck.LoginedCheck();
BLL.adminCheck.CheckWorkPower("10_1"); HttpCookie Cookie1 = Request.Cookies["adminadlogin"];
manageloginname=Cookie1["adminmanageloginname"].ToString();
managegroupid=Convert.ToInt32(Cookie1["adminmanagelevel"].ToString());
AMLogin_name=Cookie1["adminadloginname"].ToString();
AMLogin_password=Cookie1["adminadpassword"].ToString() ;
reacright=Cookie1["adminadreacright"].ToString();
Button1.Text=LAN.R2.GetString("ty_search");
// upflag.Text=LAN.R2.GetString("ty_update");
// upflag2.Text=LAN.R2.GetString("ty_update");
Confirm.Text=LAN.R2.GetString("ty_delete"); HttpCookie searchcooll = HttpContext.Current.Request.Cookies["mysearch"]; if(searchcooll !=null)
{
mysearch_c=HttpContext.Current.Request.Cookies["mysearch"]["area1"];
} stringwhere=" id>0 "+mysearch_c; if(!Page.IsPostBack)
{
ShowInfo();
} }
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 KYCMS.LAN;
using KYCMS.COMMA;
using KYCMS.BLL;
namespace KYCMS.WEB.kyzmanage.zongmanage
{
/// <summary>
/// manage_area_list 的摘要说明。
/// </summary>
public class manage_area_list : System.Web.UI.Page
{
string manageloginname;
int managegroupid;
string AMLogin_name;
string AMLogin_password;
string reacright;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Confirm,upflag,upflag2;
protected System.Web.UI.WebControls.Repeater Repeater1;
protected System.Web.UI.WebControls.TextBox kyword;
protected System.Web.UI.WebControls.DropDownList alldepid,alldepid2,alldepid3,alldepid4;
public string stringwhere,stringwhere2,mysearch_c,newskey1="",newskey2="",newskey3="",pagelinkstr;
public int intPageNo,intPageSize=20,intPageCount,RecordCount=0;
public int CurPage,mytotalpages,myonepages,totalrec;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Button up1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
string jsScript = "<script language=JavaScript> \n" +
"<!--\n" +
"function confirmDelete (frm) {\n\n" +
" // loop through all elements\n" +
" for (i=0; i<frm.length; i++) {\n\n" +
" // Look for our checkboxes only\n" +
" if (frm.elements[i].name.indexOf ('DeleteThis') !=-1) {\n" +
" // If any are checked then confirm alert, otherwise nothing happens\n" +
" if(frm.elements[i].checked) {\n" +
" return confirm (' "+ LAN.R2.GetString("ty_delete") +" ?')\n" +
" }\n" +
" }\n" +
" }\n" +
"}\n\n\n" + "function select_deselectAll (chkVal, idVal) {\n" +
"var frm = document.forms[0];\n" +
"// loop through all elements\n" +
" for (i=0; i<frm.length; i++) {\n" +
" // // Look for our Header Template's Checkbox\n" +
" if (idVal.indexOf ('CheckAll') != -1) {\n" +
" // Check if main checkbox is checked, then select or deselect datagrid checkboxes \n" +
" if(chkVal == true) {\n" +
" frm.elements[i].checked = true;\n" +
" } else {\n" +
" frm.elements[i].checked = false;\n" +
" }\n" +
" // Work here with the Item Template's multiple checkboxes\n" +
" } else if (idVal.indexOf('DeleteThis') != -1) {\n" +
" // Check if any of the checkboxes are not checked, and then uncheck top select all checkbox\n" +
" if(frm.elements[i].checked == false) {\n" +
" frm.elements[1].checked = false; // Check if any of the checkboxes are not checked, and then uncheck top select all checkbox\n" +
" }\n" +
" }\n" +
" }\n" +
"}" +
"//--> \n" +
"</script>"; //Allows our .NET page to add client-side script blocks when page loads, instead of the conventional HTML JS tags.
RegisterClientScriptBlock ("clientScript", jsScript);
WebControl button = (WebControl) Page.FindControl ("Confirm");
button.Attributes.Add ("onclick", "return confirmDelete (this.form);");
BLL.adminCheck.LoginedCheck();
BLL.adminCheck.CheckWorkPower("10_1"); HttpCookie Cookie1 = Request.Cookies["adminadlogin"];
manageloginname=Cookie1["adminmanageloginname"].ToString();
managegroupid=Convert.ToInt32(Cookie1["adminmanagelevel"].ToString());
AMLogin_name=Cookie1["adminadloginname"].ToString();
AMLogin_password=Cookie1["adminadpassword"].ToString() ;
reacright=Cookie1["adminadreacright"].ToString();
Button1.Text=LAN.R2.GetString("ty_search");
// upflag.Text=LAN.R2.GetString("ty_update");
// upflag2.Text=LAN.R2.GetString("ty_update");
Confirm.Text=LAN.R2.GetString("ty_delete"); HttpCookie searchcooll = HttpContext.Current.Request.Cookies["mysearch"]; if(searchcooll !=null)
{
mysearch_c=HttpContext.Current.Request.Cookies["mysearch"]["area1"];
} stringwhere=" id>0 "+mysearch_c; if(!Page.IsPostBack)
{
ShowInfo();
} }
{
if (Request.QueryString["CurrentPage"] != null&&pubfun.IsInt(Request.QueryString["CurrentPage"]))
{
intPageNo=Convert.ToInt32(Request.QueryString["CurrentPage"]);
}
else
{
intPageNo=1;
}
Sharetb baseclass=new Sharetb();
DataSet ds1 = baseclass.GetList("Zong_Area","*","id",intPageSize,intPageNo,0,1,stringwhere);
Repeater1.DataSource = ds1;
Repeater1.DataBind();
ds1.Clear();
ds1.Dispose();
Repeater1.Dispose(); DataSet ds0 = baseclass.GetList("Zong_Area","*","id",intPageSize,intPageNo,1,1,stringwhere);
if(ds0.Tables.Count >0 && ds0.Tables[0].Rows.Count > 0)
{
RecordCount = (int)ds0.Tables[0].Rows[0]["Total"];
} ds0.Clear();
ds0.Dispose(); pagelinkstr=CommonClass.actCutePage(RecordCount,intPageSize,intPageNo,"manage_area_list.aspx?CurrentPage=",LAN.R2.GetString("ty_unitge"),LAN.R2.Getlan());
stringwhere2="id >0" ;
DataSet catj = baseclass.GetList("Zong_Area","*","id",1000,1,0,1,stringwhere2); alldepid.Items.Add( new ListItem( LAN.R2.GetString("ty_all"), "" ) );
//alldepid4.Items.Add( new ListItem( LAN.R2.GetString("ty_all"), "" ) );
//alldepid2.Items.Add( new ListItem( LAN.R2.GetString("ty_pleaseselect"), "" ) );
//alldepid3.Items.Add( new ListItem( LAN.R2.GetString("ty_pleaseselect"), "" ) ); //alldepid3.Items.Add( new ListItem( LAN.R2.GetString("ty_open"), "1" ) );
//alldepid3.Items.Add( new ListItem( LAN.R2.GetString("ty_close"), "0" ) );
//alldepid4.Items.Add( new ListItem( LAN.R2.GetString("ty_open"), "1" ) );
//alldepid4.Items.Add( new ListItem( LAN.R2.GetString("ty_close"), "0" ) );
int forumColumnCount=catj.Tables[0].Rows.Count; if(forumColumnCount > 0)
{
for(int j = 0;j < forumColumnCount;j++)
{
alldepid.Items.Add( new ListItem( catj.Tables[0].Rows[j]["name"].ToString(),catj.Tables[0].Rows[j]["id"].ToString().Trim() ) );//增加Item
//alldepid2.Items.Add( new ListItem( catj.Tables[0].Rows[j]["name"].ToString(),catj.Tables[0].Rows[j]["id"].ToString().Trim() ) );//增加Item
} }
catj.Clear();
catj.Dispose();
}
public void deleteuser(object sender, System.EventArgs e)
{
string logid, udir,messstr=LAN.R2.GetString("ty_dowitherror") ;
int repCount = Repeater1.Items.Count;
for(int i = 0; i<repCount;i++)
{
if(((CheckBox)Repeater1.Items[i].FindControl("DeleteThis")).Checked==true)
{
logid= ((Label)Repeater1.Items[i].FindControl("logid")).Text.Trim().ToString();
// Basecontent Bsct=new Basecontent();
// udir= Bsct.getsitedir(logid);
Zong_Area baseclass=new Zong_Area();
//COMMA.CommonClass.Deletedir(System.Web.HttpContext.Current.Server.MapPath("/"+udir+"/"+logid+"/"));
baseclass.Delete(Convert.ToInt32(logid));
//baseclass.Delete(logid);
messstr=LAN.R2.GetString("ty_dowithok") ; }
}
CommonClass.MsgBox2(messstr,"manage_area_list.aspx");
}
// public void update_memflag(object sender, System.EventArgs e)
// {
// Sharetb baseclass=new Sharetb();
// string logid,delstringwhere, messstr=LAN.R2.GetString("ty_dowitherror") ;
// int repCount = Repeater1.Items.Count,dirid;
// for(int i = 0; i<repCount;i++)
// {
// if(((CheckBox)Repeater1.Items[i].FindControl("DeleteThis")).Checked==true)
// {
// logid= ((Label)Repeater1.Items[i].FindControl("logid")).Text.Trim().ToString();
// if (logid!=""&&alldepid2.SelectedItem.Value.Trim() != ""&&alldepid2.SelectedItem.Value.Trim()!= null)
// {
// dirid=Convert.ToInt32(alldepid2.SelectedItem.Value.Trim());
//
// delstringwhere="update Zong_Area set usergroup='"+dirid+"' where uloginname='"+logid+"'";
// baseclass.ExeSql(delstringwhere);
// messstr=LAN.R2.GetString("ty_dowithok") ;
// }
//
// }
//
// }
// CommonClass.MsgBox2(messstr,"manage_general_user.aspx");
// }
// public void update_memflag2(object sender, System.EventArgs e)
// {
// Sharetb baseclass=new Sharetb();
// string logid,delstringwhere, messstr=LAN.R2.GetString("ty_dowitherror") ;
// int repCount = Repeater1.Items.Count,dirid;
// for(int i = 0; i<repCount;i++)
// {
// if(((CheckBox)Repeater1.Items[i].FindControl("DeleteThis")).Checked==true)
// {
// logid= ((Label)Repeater1.Items[i].FindControl("logid")).Text.Trim().ToString();
// if (logid!=""&&alldepid3.SelectedItem.Value.Trim() != ""&&alldepid3.SelectedItem.Value.Trim()!= null)
// {
// dirid=Convert.ToInt32(alldepid3.SelectedItem.Value.Trim());
//
// delstringwhere="update Zong_Area set uuserstatus='"+dirid+"' where uloginname='"+logid+"'";
// baseclass.ExeSql(delstringwhere);
// messstr=LAN.R2.GetString("ty_dowithok") ;
// }
//
// }
//
// }
// CommonClass.MsgBox2(messstr,"manage_general_user.aspx");
// }
// public string Getcityname(string status)
// {
// string name="No";
// if (status!= "")
// {
// int mstatus=Convert.ToInt32(status);
// //name=baseclass.getblog_class_byclassid(mstatus,"class_name");
// }
//
// return name;
// }
// public string Getusergroupname(string statusid)
// {
// return CommonClass.Getcatstatus(LAN.R2.Getlan(),statusid);
// }
// public string Formatstatus(string status)
// {
// string name="<font color=red>No</font>";
// if (status!= "")
// {
// int mstatus=Convert.ToInt32(status);
// KYCMS.BLL.Zong_Area bll=new KYCMS.BLL.Zong_Area();
// KYCMS.Model.Zong_Area model=bll.GetModel(mstatus);
// if (model!=null)
// {
// name=model.name;
// //name=baseclass.getblog_class_byclassid(mstatus,"class_name");
// }
// }
//
// return name;
// }
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
public void Button1_Click(object sender, System.EventArgs e)
{
if (kyword.Text.Trim()!=""&&kyword.Text.Trim()!= null)
{
newskey1="and (name like '%"+PageValidate.InputText(PageValidate.WipeScript(kyword.Text.Trim()),100)+"%' or num like '%"+PageValidate.InputText(PageValidate.WipeScript(kyword.Text.Trim()),100)+"%' )";
}
if (alldepid.SelectedItem.Value.Trim() != ""&&alldepid.SelectedItem.Value.Trim()!= null)
{
newskey2="and name='"+alldepid.SelectedItem.Value.Trim()+"'";
}
stringwhere=newskey2+newskey1; if ((newskey2!="")||(newskey1!=""))
{
HttpCookie aCookie=new HttpCookie("mysearch");
aCookie.Values.Add("area1",stringwhere);
Response.Cookies.Add(aCookie);
Response.Redirect("manage_area_list.aspx");
}
else
{
Response.Cookies["mysearch"].Value = null;
Response.Cookies["mysearch"].Expires = System.DateTime.Now.AddMonths(-10); //上个月
Response.Redirect("manage_area_list.aspx");
}
}
}
}
太多了,不知道你是用的过程还是写的语句
如果你写的语句,建议你把查询部分在SQL中写个过程效果会更好
最简单的方法:设置断点调试,每一步都跟进去看看,
得到的SQL语句直接在数据库中查询一遍。
//断点调试到这里 看看 stringwhere 值是什么
stringwhere=newskey2+newskey1;
然后问题解决。