are you using databinding? if so, do it insideif (!IsPostBack)
{
//dropdownlist.databind();
}
{
//dropdownlist.databind();
}
解决方案 »
- 急! .xpi文件如何下载完自动安装
- 怎样让正则只匹配一次呢?
- 验证控件问题
- asp的 hyperlink和image控件的图片显示???
- 我想要一.net个人空间源码,具有以下功能
- 为何ResponseText得到的是包含<HTML></HTML>格式的字符串?
- .NET小常识——答你所问
- 有没有 一个函数可以得到远端机器 iis虚拟目录下的所有文件名?
- 实现checkboxlist 的查询,我用的是存储过程,哪位大虾能给出源码!万分感激!
- 关于标签跳转的一个小问题,急!!!!!!
- datalist的问题 请给个简单的例子(JSP或者VB代码)问题解决就给分
- 简单的老问题,asp.net中的messagebox
{
// 在此处放置用户代码以初始化页面
// if(Page.IsPostBack)
// Response.Redirect("index.aspx");
string sql;
try
{
//新闻信息显示
sql="select top 4 id,picture,cname,price,preferentialprice from product order by inputdate desc";
DataSet ds=zddata.dbbind(sql,"product");
productindex1.DataSource=ds.Tables["product"].DefaultView;
productindex1.DataBind();
sql="select top 4 news.id as nid,cname,title,case new when 1 then '新' when 0 then '' end as newsstate1,case hot when 1 then ' 热' when 0 then '' end as newsstate2 from news,newscat where news.catid=newscat.id order by pubdate desc";
ds=zddata.dbbind(sql,"product");
newsindex1.DataSource=ds.Tables["product"].DefaultView;
newsindex1.DataBind(); //商品搜索初始化,商品类型使用的是商品的二级分类信息
sql="select id,cname from productcat";
ds=zddata.dbbind(sql,"productcat");
DropListclass.DataSource=ds.Tables["productcat"].DefaultView;
DropListclass.DataTextField="cname";
DropListclass.DataValueField="id";
DropListclass.DataBind(); }
catch(Exception ex)
{
HttpContext.Current.Response.Write(ex.ToString());}private void InitializeComponent()
{
this.searchBut.Click += new System.EventHandler(this.searchBut_Click);
this.Btn1.ServerClick += new System.EventHandler(this.Btn1_ServerClick);
this.Btn2.ServerClick += new System.EventHandler(this.Btn2_ServerClick);
this.Load += new System.EventHandler(this.Page_Load);}
{
if (!IsPostBack)
{
string sql;
try
{
//新闻信息显示
sql="select top 4 id,picture,cname,price,preferentialprice from product order by inputdate desc";
DataSet ds=zddata.dbbind(sql,"product");
productindex1.DataSource=ds.Tables["product"].DefaultView;
productindex1.DataBind();
sql="select top 4 news.id as nid,cname,title,case new when 1 then '新' when 0 then '' end as newsstate1,case hot when 1 then ' 热' when 0 then '' end as newsstate2 from news,newscat where news.catid=newscat.id order by pubdate desc";
ds=zddata.dbbind(sql,"product");
newsindex1.DataSource=ds.Tables["product"].DefaultView;
newsindex1.DataBind(); //商品搜索初始化,商品类型使用的是商品的二级分类信息
sql="select id,cname from productcat";
ds=zddata.dbbind(sql,"productcat");
DropListclass.DataSource=ds.Tables["productcat"].DefaultView;
DropListclass.DataTextField="cname";
DropListclass.DataValueField="id";
DropListclass.DataBind(); }
catch(Exception ex)
{
HttpContext.Current.Response.Write(ex.ToString());
}
}
}
搞定!!收工!!