ListBox问题,高手请进! Page_Load中加if(!IsPostBack){listbox数据绑定;} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不会吧,绑定是否放在!IsPostBack中呢 你是不是选择了autopostback,如果选择了,重新绑定的话肯定跳到第一项啦 private void Page_Load(object sender, System.EventArgs e) { if(!IsPostBack) { InitList(); } }private void InitList() { this.lstList.Items.Clear(); SqlConnection myConn=new SqlConnection(myConnStr); string myCmdStr="Select * from user order by name"; SqlCommand myCmd=new SqlCommand(myCmdStr,myConn); SqlDataAdapter myAdapter=new SqlDataAdapter(myCmd); DataSet myDS=new DataSet(); myAdapter.Fill(myDS,"User"); this.lstList.DataSource=myDS; this.lstList.DataMember="manufactory"; this.lstList.DataTextField="name"; this.lstList.DataValueField="url"; this.lstList.DataBind(); } autopostback加不加都一样,只有在只绑定text是listbox操作正常 将初始化代码放在!IsPostBack中 value和text是关联的,所以只能绑一个 这可能是一个bug,昨晚我用新版的.NET试了一下,没有这个问题,如果再没有人有好的解决方案我就结贴了! url不要后缀名的地址重写 ListView和DataPager实现分页,导出所有数据到Excel gridview中的label如何绑定显示 关于取登录者的信息 Intelligencia.UrlRewriter组件问题,不能够转移到设定的URL 关于母版页控件调用的问题 [100分问题]高手请进~这个问题一般人遇不到--在线等,急急急~ 注册SQL SERVER实例! 如何判断SQL SERVER 中 Image型字段是否为空值 如何将一个partialView传入一个View中,并调用View中的JS方法? 如何删除以上传的文件?急啊,高分求救! 小女子刚学.net ,怎么开始?
{
if(!IsPostBack)
{
InitList();
}
}
private void InitList()
{
this.lstList.Items.Clear();
SqlConnection myConn=new SqlConnection(myConnStr);
string myCmdStr="Select * from user order by name";
SqlCommand myCmd=new SqlCommand(myCmdStr,myConn);
SqlDataAdapter myAdapter=new SqlDataAdapter(myCmd);
DataSet myDS=new DataSet();
myAdapter.Fill(myDS,"User");
this.lstList.DataSource=myDS;
this.lstList.DataMember="manufactory";
this.lstList.DataTextField="name";
this.lstList.DataValueField="url";
this.lstList.DataBind();
}
!IsPostBack中