zoukankan      html  css  js  c++  java
  • 下拉菜单DropDownList无法插入项 Items.Insert unavailable Fred

    这个问题我想一般开发人员很少会遇到,但偏偏被我的粗心大意给遇到啦。
    情况是这样:我先给DropDownList控件绑定了数据源,然后用DropDownList.Items.Insert(0,new ListItem("全部...",""))插入一条项,但是经过N出调整和编译,始终无法显示新插入的那条“全部...”到DropDownList中。

    原先的代码如下:
    protected void Page_Load(object sender, EventArgs e)
            {
                
    if (!IsPostBack)
                {
                    Uni.TransLanguage(
    this.Controls);
                    Uni.bindDropDownList(ddlType, 
    "type_information_res""res");
                    
    this.ddlType.Items.Insert(0new ListItem("全部"""));

                    BindData();
                }
            }

            
    // 绑定数据
            protected void BindData()
            {
                ServiceRefInfo.DbInfoAccessClient client 
    = new tcShare.ServiceRefInfo.DbInfoAccessClient();
                
    string strWhere = "status=1 and dict_type='type_information_res' and dict_type2='type_information_res'";
                AspNetPager1.RecordCount 
    = client.GetImDdResListRecordCount(strWhere);
                gvDocResList.DataSource 
    = client.GetImDdResList(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, strWhere);
                
    this.DataBind(); 

                client.Close();
            }

    问题所在:原来是GridView进行DataBind()的时候,我写成了this.DataBind();编译竟然可以通过!列表什么都可以显示,期待高手给与解释。
  • 相关阅读:
    Linux工具[转]
    [C++]线程池 与 [Go] mapreduce
    快手面试代码题
    C++ note
    sudo与用户权限
    service 与 log日志
    tmux-cheatsheet
    [转]Linux下的常见信号总结
    记一个低级错误
    Github个人主页不显示提交记录的问题
  • 原文地址:https://www.cnblogs.com/Fred_Xu/p/1558085.html
Copyright © 2011-2022 走看看