网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的考试资料:

 

标题 获取DropDownList的SelectIndex的时候只能是0
内容
    由于初始化判断出错导致每次传到服务器的时候会初始化一次,这就导致每次获取DropDownList的SelectIndex的时候只能是0
    代码如下:
    <asp:DropDownList ID="ddlNameList" runat="Server" Height="30"
    AutoPostBack="True" onselectedindexchanged="ddlNameList_SelectedIndexChanged" ></asp:DropDownList>
    2.在服务端处理的时候,尤其是初始化DropDownList的时候,没注意结果写错了,下面是错误代码:
    代码如下:
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!Page.IsCallBack)
    {
    this.fillIntoNameList();
    }
    }
    这个初始化判断出错了,每次传到服务器的时候会初始化一次,这就导致每次获取DropDownList的SelectIndex的时候只能是0
    正确代码,如下:
    代码如下:
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!Page.IsPostBack)
    {
    this.fillIntoNameList();
    }
    }
随便看

 

在线学习网考试资料包含高考、自考、专升本考试、人事考试、公务员考试、大学生村官考试、特岗教师招聘考试、事业单位招聘考试、企业人才招聘、银行招聘、教师招聘、农村信用社招聘、各类资格证书考试等各类考试资料。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/17 22:52:24