搜索按钮修改 [英] search button modify

查看:78
本文介绍了搜索按钮修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有搜索按钮的网络表单,该按钮使用empID和LANID返回员工详细信息。它工作得很好,它从Dictionary获取数据。


我想在文本字段中添加功能,输入员工姓名(最后一个),当你点击按钮时,您将获得结果显示在下拉列表中。然后单击下拉列表中的名称,然后使用
填充表单,就像使用LANID和empID搜索时的员工详细信息一样。


这是我的方式按钮代码如下所示:


使用System;

使用System.Collections.Generic;

使用System.Linq;

使用System.Web;

使用System.Web.UI;

使用System.Web.UI.WebControls;

使用System。诊断;

使用CatSearch.Search;



命名空间xxx.CatSearch

{

   公共部分类CatRollupSearch:System.Web.UI.Page

    {

        protected void Page_Load(object sender,EventArgs e)

        {

$
        }


        protected void Button1_Click(object sender,EventArgs e)

        {

            SearchBy srchBy;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;字典< Rollup,CatInformation> myCatList = new Dictionary< Rollup,CatInformation>();

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string _Identifier = this.TextBoxSearchParameter.Text;
$


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;试试
  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(String.IsNullOrEmpty(_Identifier))

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;抛出新的System.ArgumentException("搜索参数不能为null或为空",_Identifier);

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }


  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; switch(int.Parse(this.RadioButtonList1.SelectedValue))

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;案例1:srchBy = SearchBy.ByCatID;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;休息;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;案例5:srchBy = SearchBy.ByLanID;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;休息;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;默认值:

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; srchBy = SearchBy.ByCatID;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;休息;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }




  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;   Cat mycat =新猫(_Identifier,srchBy,Rollup.DirectReport);

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; EmployeeInformation CatInfo = new CatInformation();



  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;   CatInfo = myCat.MyCatInformation;



  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_email.Text = CatInfo.Email;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_EmpoyeeID.Text = string.Format(" {0:}",long.Parse(CatInfo.CatID));

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_fName.Text = CatInfo.FirstName;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_fullName.Text = CatInfo.FullName;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_HRStatus.Text = CatInfo.HRStatus;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_jobTitle.Text = CatInfo.JobTitle;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_LanID.Text =(CatInfo.LanID).Substring((CatInfo.LanID).LastIndexOf(" \\")+ 1);

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_LastHireDate.Text = String.Format(" {0:d}",CatInfo.LastHireDate);

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_lName.Text = CatInfo.LastName;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_mInitial.Text = HMCInfo.MiddleInitial;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_mName.Text = CatInfo.MiddleName;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_OriginalHireDate.Text = String.Format(" {0:d}",CatInfo.OriginalHireDate);

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_positionDate.Text = String.Format(" {0:d}",CatInfo.PositionDate);

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_RegTemp.Text = CatInfo.RegTemp;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_TerminationDate.Text = String.Format(" {0:d}",CatInfo.TerminationDate);



  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; //管理级别0

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr0Email.Text = myCat._managerInfo.Email;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr0EmpoyeeID.Text = string.Format(" {0:}",long.Parse(myCat._managerInfo.EmpID));

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr0FullName.Text = myCat._managerInfo.FullName;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr0JobTitle.Text = myCat._managerInfo.JobTitle;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr0LoginID.Text =(myCat._managerInfo.LanID).Substring((myCat._managerInfo.LanID).LastIndexOf(" \\")+ 1);



  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; //管理级别1

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr1Email.Text = myCat._managerInfo1.Email;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr1EmpoyeeID.Text = string.Format(" {0:}",long.Parse(myCat._managerInfo1.CatID));

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr1FullName.Text = myCat._managerInfo1.FullName;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr1JobTitle.Text = myCat._managerInfo1.JobTitle;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr1LoginID.Text =(myHMC._managerInfo1.LanID).Substring((myCat._managerInfo1.LanID).LastIndexOf(" \\")+ 1);



  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; //管理级别2

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr2Email.Text = myCat._managerInfo2.Email;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr2EmpoyeeID.Text = string.Format(" {0:}",long.Parse(myCat._managerInfo2.CatID));

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr2FullName.Text = myCat._managerInfo2.FullName;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr2JobTitle.Text = myCat._managerInfo2.JobTitle;

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; this.Txb_Mngr2LoginID.Text =(myHMC._managerInfo2.LanID).Substring((myCat._managerInfo2.LanID).LastIndexOf(" \\")+ 1); ;



$
  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; catch(例外情况)

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Debug.WriteLine(" Error:" + ex.Message +"," + ex.Source +" \\\
Trace ::" + ex.StackTrace +" \ n Inner Exception:" + ex.InnerException);

  &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }


  &NBSP; &NBSP; &NBSP; }


  &NBSP; &NBSP; &NBSP; protected void RadioButtonList1_SelectedIndexChanged(object sender,EventArgs e){
$


  &NBSP; &NBSP; &NBSP; }¥b $ b  &NBSP; } b $ b}

解决方案

嗨winkimjr2,


你更有可能获得在
http://forums.asp.net
上更有效地回应ASP.NET问题,您可以在这里与ASP.NET专家联系


I have a web form with a search button which uses empID and LANID to return employee details. It is working great and it gets the data from Dictionary.

I want to add the capability where you can in the text field enter the employee name (last) and when you click on the button, you get results displayed in a dropdown list. Then you click on the name from the dropdown list and then the form is populated with the employee details like it is when you search by LANID and empID.

Here is how my button code looks like:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
using CatSearch.Search;

namespace xxx.CatSearch
{
    public partial class CatRollupSearch : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SearchBy srchBy;
            Dictionary<Rollup, CatInformation> myCatList = new Dictionary<Rollup, CatInformation>();
            string _Identifier = this.TextBoxSearchParameter.Text;

            try
            {
                if (String.IsNullOrEmpty(_Identifier))
                {
                    throw new System.ArgumentException("Search Parameter cannot be null or empty", _Identifier);
                }

                switch (int.Parse(this.RadioButtonList1.SelectedValue))
                {
                    case 1: srchBy = SearchBy.ByCatID;
                        break;
                    case 5: srchBy = SearchBy.ByLanID;
                        break;
                    default:
                        srchBy = SearchBy.ByCatID;
                        break;
                }


                 Cat mycat = new cat(_Identifier, srchBy, Rollup.DirectReport);
                EmployeeInformation CatInfo = new CatInformation();

                 CatInfo = myCat.MyCatInformation;

                this.Txb_email.Text = CatInfo.Email;
                this.Txb_EmpoyeeID.Text = string.Format("{0:}", long.Parse(CatInfo.CatID));
                this.Txb_fName.Text = CatInfo.FirstName;
                this.Txb_fullName.Text = CatInfo.FullName;
                this.Txb_HRStatus.Text = CatInfo.HRStatus;
                this.Txb_jobTitle.Text = CatInfo.JobTitle;
                this.Txb_LanID.Text = (CatInfo.LanID).Substring((CatInfo.LanID).LastIndexOf("\\") + 1);
                this.Txb_LastHireDate.Text = String.Format("{0:d}", CatInfo.LastHireDate);
                this.Txb_lName.Text = CatInfo.LastName;
                this.Txb_mInitial.Text = HMCInfo.MiddleInitial;
                this.Txb_mName.Text = CatInfo.MiddleName;
                this.Txb_OriginalHireDate.Text = String.Format("{0:d}", CatInfo.OriginalHireDate);
                this.Txb_positionDate.Text = String.Format("{0:d}", CatInfo.PositionDate);
                this.Txb_RegTemp.Text = CatInfo.RegTemp;
                this.Txb_TerminationDate.Text = String.Format("{0:d}", CatInfo.TerminationDate);

                //Management Level 0
                this.Txb_Mngr0Email.Text = myCat._managerInfo.Email;
                this.Txb_Mngr0EmpoyeeID.Text = string.Format("{0:}", long.Parse(myCat._managerInfo.EmpID));
                this.Txb_Mngr0FullName.Text = myCat._managerInfo.FullName;
                this.Txb_Mngr0JobTitle.Text = myCat._managerInfo.JobTitle;
                this.Txb_Mngr0LoginID.Text = (myCat._managerInfo.LanID).Substring((myCat._managerInfo.LanID).LastIndexOf("\\") + 1);

                //Management Level 1
                this.Txb_Mngr1Email.Text = myCat._managerInfo1.Email;
                this.Txb_Mngr1EmpoyeeID.Text = string.Format("{0:}", long.Parse(myCat._managerInfo1.CatID));
                this.Txb_Mngr1FullName.Text = myCat._managerInfo1.FullName;
                this.Txb_Mngr1JobTitle.Text = myCat._managerInfo1.JobTitle;
                this.Txb_Mngr1LoginID.Text = (myHMC._managerInfo1.LanID).Substring((myCat._managerInfo1.LanID).LastIndexOf("\\") + 1);

                //Management Level 2
                this.Txb_Mngr2Email.Text = myCat._managerInfo2.Email;
                this.Txb_Mngr2EmpoyeeID.Text = string.Format("{0:}", long.Parse(myCat._managerInfo2.CatID));
                this.Txb_Mngr2FullName.Text = myCat._managerInfo2.FullName;
                this.Txb_Mngr2JobTitle.Text = myCat._managerInfo2.JobTitle;
                this.Txb_Mngr2LoginID.Text = (myHMC._managerInfo2.LanID).Substring((myCat._managerInfo2.LanID).LastIndexOf("\\") + 1); ;


            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error: " + ex.Message + ", " + ex.Source + "\n Trace:: " + ex.StackTrace + "\n Inner Exception: " + ex.InnerException);
            }

        }

        protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e){

        }
    }
}

解决方案

Hi winkimjr2,

You are more likely to get more efficient responses to ASP.NET issues at http://forums.asp.net where you can contact ASP.NET experts.


这篇关于搜索按钮修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆