listBox后台绑定的方法 到底放在那个位置
时间:2011-12-23
来源:互联网
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using Gethome.Model;
using Gethome.Web.UI.Control;
using Gethome.Common;
using System.Collections.Generic;
namespace Gethome.Web.AddEvent
{
public partial class AddEvent2 : Gethome.Web.UI.Page.BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
}
这个方法到底是放在Page.IsPostBack里面还是外面,放在里面。我点击添加按钮列表就没了。下面还是没取出什么值
FriendBind();
}
listBox绑定方法
protected void FriendBind()
{
int UserID = this.GetUserID();
IList<FriendInfo> list = new Gethome.BLL.User.Friend().GerListFriend(UserID);
foreach (FriendInfo fd in list)
{
ListItem li = new ListItem();
li.Text = fd.userBasic.RealName;
li.Value = fd.userBasic.UserID.ToString(); ;
Lb_Friend.Items.Add(li);
}
}
这个地方Lb_Friend.Items[i].Selected 一直是False,一直没进去。急死我了。
protected void SelectFrind_Click(object sender, EventArgs e)
{
string Participant = "";
string ParticipantId = "";
for (int i = 0; i < Lb_Friend.Items.Count; i++)
{
if (Lb_Friend.Items[i].Selected == true)
{
int UserID =Convert.ToInt32(Lb_Friend.Items[i].Value);
UserBasicInfo ub = new Gethome.BLL.User.User().GetUserBasic(UserID);
Participant += ub.RealName + ",";
ParticipantId += ub.UserID+",";
}
}
Txt_Participant.Text = Participant;
Hid_Participant.Value = ParticipantId;
}
}
}
大哥大姐们。看的说下了。那个绑定方法是不是有什么不对的。为什么一直是False,取不到值呀,
作者: xcy_wwj 发布时间: 2011-12-23
{//绑定数据}
可无刷新操作。在外面回传重新绑定
作者: wuyq11 发布时间: 2011-12-23
作者: Return_false 发布时间: 2011-12-23
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; //在retrun 后面写你的操作 FriendBind(); }
作者: w290601645 发布时间: 2011-12-23
作者: xcy_wwj 发布时间: 2011-12-23
作者: jianghui7897 发布时间: 2011-12-23
if (!Page.IsPostBack)
{
}
//如果出现你4楼所说的情况,请检查是否禁止了页面或该控件的状态保存属性
protected void SelectFrind_Click(object sender, EventArgs e)
{
Txt_Participant.Text =Lb_Friend.Items.Count.ToString();//你这里尝试显示下拉框的数据项看下,估计是0
}
作者: likevs 发布时间: 2011-12-23
作者: xcy_wwj 发布时间: 2011-12-23
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28