下拉加载问题 [英] Drop Down Loading problem

查看:107
本文介绍了下拉加载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个下拉列表.因为我已经给出了一个条件,例如第一次加载页面时,我们必须在顶部显示--select--,这意味着在显示下拉值之前显示--select--值.我的问题是单击任何按钮时在该页面中,条件不起作用意味着-选择-未显示在下拉列表的顶部.

解决方案

请参见dropdownlist的AutoPostBack属性.

 尝试 代码

 尝试
        {
            ds = " 
            如果(ds.Tables.Count >   0 )
            {
                如果(ds.Tables [ 0 ].Rows.Count  >   0 )
                {
                    ddl_InterviewCategory.DataSource = ds;
                    ddl_InterviewCategory.DataTextField = " ;
                    ddl_InterviewCategory.DataValueField = " ;
                    ddl_InterviewCategory.DataBind();
                }
                ddl_InterviewCategory.Items.Insert( 0 " );
            }
        }
        捕获(例外)
        {
         ex;
        }
// 设置ddl.SelectedValue ="0";您需要在哪里显示----------在顶部 


u必须插入--- select ---像这样在加载

 dropdownlist.Items.Insert( 0 " ); 


Hi,
I have a drop down list. in that i have given a condition like when page is first loading we have to display --select-- at the top, means before the drop down values am displaying -- select-- value.. My problem is when am clicking any button in that page the condition is not working means -- select-- is not displaying at the top of dropdown list.

解决方案

See AutoPostBack property of dropdownlist.


try this code

 try
        {
            ds = "YourCode"
            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    ddl_InterviewCategory.DataSource = ds;
                    ddl_InterviewCategory.DataTextField = "Name";
                    ddl_InterviewCategory.DataValueField = "Value";
                    ddl_InterviewCategory.DataBind();
                }
                ddl_InterviewCategory.Items.Insert(0, "----Select----");
            }
        }
        catch (Exception ex)
        {
        throw ex;
        }
// Set ddl.SelectedValue = "0"; where ever you need to display ----Select-- on top


u have to insert ---select--- like this on load

dropdownlist.Items.Insert(0, "---Select---");


这篇关于下拉加载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆