public partial class app_BridgeInfo : System.Web.UI.Page
{
private string opt; //操作类型 add:添加 update:修改
private string id; //ID
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Response.Expires = -1; //取消该页缓存
opt = Request.QueryString["opt"] != null ? Request.QueryString["opt"].ToString() : "";
id = Request.QueryString["id"] != null ? Request.QueryString["id"].ToString() : "0";
if (id == "")
{
CommonJS.AlertMessage(this.Page, "操作错误!", "0");
}
HFID.Value = id;
Handler();
BindDate();
}
}
/// <summary>
/// 绑定下拉列表信息
/// </summary>
/// <param name="id"></param>
private void BindDate()
{
lbCode.DataSource = BLLBridge.Select();
lbCode.TextField = "Name";
lbCode.ValueField = "Code";
lbCode.DataBind();
}
或:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) ;
{
bindTitle();
}
}
//进行数据绑定
private void bindTitle()
{//对一个下拉列表的数据绑定
DB dbSource = new DB();
SqlDataReader dateSoure = dbSource.getSdr("select id,voteTitle from voteMaster");
this.ddlVoteTitle.DataSource = dateSoure;
this.ddlVoteTitle.DataValueField = "id";
this.ddlVoteTitle.DataTextField = "voteTitle";
this.ddlVoteTitle.DataBind();
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/meng1986/archive/2007/08/04/1726332.aspx