asp.net中,我想在页面加载时拿到DropDownLis控件里面的索引值,我用ddlType.SelectedIndex获取的总是0,是为什么?
解决方案 »
- [color=#FF0000]asp.net操作word问题,有过相关经验的劳驾关注下[/color][只有这么多分了]
- 关于把Session存入SQLServer的问题 急!!!!
- delete * from eq_param a,equip_info b where b a.mt_id=b.id 错了吗
- 请教一个C#画图程序,高手帮忙看看
- 设置框架的固定高度
- 关于定时器的问题
- ajax 1.0问题
- 在datagrid中怎样实现输入页码跳转到指定的页
- 火车时刻站站查询的问题
- 参数传递问题
- WEB下TREEVIEW实现网络硬盘
- 怎么在页面跳转的时候给以用户保存提示?像www.51.com这个博客的跳转方式
明显没有把绑定放在 ispostback 里面
public partial class message_message : System.Web.UI.Page
{
private MessageManager mm = new MessageManager();
private int type; //
#region 加载
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
type = ddlType.SelectedIndex;//获取dropDownList的索引
ViewState["page"] = 0;
MsgBind(type);
}
}
#endregion #region 数据绑定
private void MsgBind(int type)
{
PagedDataSource pds = new PagedDataSource();
pds.AllowPaging = true;
pds.CurrentPageIndex = Pager;
pds.PageSize = 5;
lblcurrentPage.Text = "第" + (pds.CurrentPageIndex + 1).ToString() + "页 共" + (pds.PageCount.ToString())+"页";
pds.DataSource = mm.GetAllMessages(type); SetEnable(pds); //用于设置上下按钮的有效状态
dlMessage.DataSource = pds;
dlMessage.DataBind();
}
#endregion
放到if (!IsPostBack) {} 的外面就可以了
在if (!IsPostBack) {} 里面加载绑定方法