一个实现查询功能的asp.net控件

本人新手,刚做项目要实现很多的按分类查询,于是自己做了歌查询控件.

以下是源代码,大家勉强看看吧,别笑话小子啊;

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;

namespace SearchControl
{
 /// <summary>
 /// Search 的摘要说明。
 /// </summary>
 
 public class Search : System.Web.UI.Control,INamingContainer
 {
  private System.Web.UI.WebControls.TextBox txtCondition;
  private System.Web.UI.WebControls.DropDownList ddlContent;
  private System.Web.UI.WebControls.Button btnSearch;
  public event System.EventHandler ToSearch;
  public Search()
  {
   this.EnsureChildControls();
   this.btnSearch.Click +=new EventHandler(btnSearch_Click);
  }
  public string Text
  {
   get{return this.txtCondition.Text;}
   set{this.txtCondition.Text=value;}
  }
  public object DataSource
  {
   get{return this.ddlContent.DataSource;}
   set{ddlContent.DataSource=value;}
  }
  public string DataTextField
  {
   get{return this.ddlContent.DataTextField;}
   set{this.ddlContent.DataTextField=value;}
  }
  public string DataValueField
  {
   get{return this.ddlContent.DataValueField;}
   set{this.ddlContent.DataValueField=value;}
  }
  public string SelectValue
  {
   get{return this.ddlContent.SelectedValue;}
   set{this.ddlContent.SelectedValue=value;}
  }
  public string SelectText
  {
   get{return this.ddlContent.SelectedItem.Text;}
  }
  public void DataBind()
  {
   this.ddlContent.DataBind();
  }
//  public ListItemCollection Items
//  {
//   get{return this.ddlContent.Items;}
//  }
  public string ButtonText
  {
   get{return this.btnSearch.Text;}
   set{this.btnSearch.Text=value;}
  }
  protected override void CreateChildControls()
  {
   txtCondition=new TextBox();
   this.ddlContent=new DropDownList();
   this.btnSearch=new Button();
   this.btnSearch.Text="查询";
   System.Web.UI.WebControls.Literal []lt=new Literal[2];
   for(int i=0;i<lt.Length;i++)
   {
    lt[i]=new Literal();
    lt[i].Text="&nbsp;&nbsp;";
   }
   this.Controls.Add(txtCondition);
   this.Controls.Add(lt[0]);
   this.Controls.Add(this.ddlContent);
   this.Controls.Add(lt[1]);
   this.Controls.Add(this.btnSearch);
  }
  private void btnSearch_Click(object sender,EventArgs e)
  {
   if(ToSearch!=null)
   {
    ToSearch(this,e);
   }
  }
 }
}
 

主要实现功能是,在文本框中输入查询内容,下拉框中可选择查询查询范围,比如分类,时间==,点击按钮开始查询,

做好的控件外观如下:

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值