FineUI 官方论坛

标题: 三石老大,帮忙解决一下DropDownList1.SelectedValue [打印本页]

作者: yygy    时间: 2013-7-2 20:44
标题: 三石老大,帮忙解决一下DropDownList1.SelectedValue
本帖最后由 yygy 于 2013-7-3 09:47 编辑

DropDownList1动态增加数据,当数据(3)不存在时,按回车可以增加数据,但DropDownList1.SelectedValue 下拉框的位置不对,怎样解决,请老大解决一下。图1是运行的结果,但我想要的结果是图2
<body>
    <form id="form1" runat="server">
    <xageManager ID="ageManager1" runat="server" />
    <xropDownList runat="server" ID="DropDownList1" EnableEdit="true" ForceSelection="false">
    </xropDownList>
        <x:TextBox runat="server" Hidden="true" ID="TextBox1">
    </x:TextBox>
    </form>
</body>
<script type="text/javascript">
    function onReady() {
        DropDownList1 = Ext.getCmp('<%= DropDownList1.ClientID %>');
        DropDownList1.on("specialkey", function (box, e) {
            if (e.getKey() == e.ENTER || e.getKey() == 9) {
                if (box.lastQuery != "" && box.lastQuery != undefined) {
                    if (confirm("输入无效,是否要新增数据?")) {
                        __doPostBack("DropDownList1", box.lastQuery);
                    }
                }
            }
        });
    }
</script>
        protected void Page_Load(object sender, EventArgs e)
        {
            string controlName = Request.Params.Get("__EVENTTARGET");
            string eventArgument = Request.Params.Get("__EVENTARGUMENT");
            if (controlName == "DropDownList1")
            {
                DropDownList1.Items.Add(new FineUI.ListItem(eventArgument, eventArgument));
                DropDownList1.SelectedValue = eventArgument;
            }
            if (!IsPostBack)
            {
                BindStringListToDropDownList();
            }
        }
        private void BindStringListToDropDownList()
        {
            List<string> strList = new List<string>();
            strList.Add("1");
            strList.Add("2");
            DropDownList1.DataSource = strList;
            DropDownList1.DataBind();
        }
    }[attach]2615[/attach]


作者: sanshi    时间: 2013-7-3 11:15
没看明天,第一个图数据“3”不是存在么,应该会选择数据“3”?
作者: yygy    时间: 2013-7-3 11:31
本帖最后由 yygy 于 2013-7-3 11:43 编辑

"3"是存在,但是下拉框的位置不是在"3"而是个“1”{:soso_e109:}
作者: yygy    时间: 2013-7-3 11:35
如果再按回车,“3”就会变成“1”
作者: yygy    时间: 2013-7-3 21:07
本帖最后由 yygy 于 2013-7-3 21:09 编辑

DropDownList1.SelectedValue 不能定位,跟我上次提的问题一样http://www.fineui.com/bbs/forum. ... ead&tid=3342&extra=,这可能是个BUG,老大抽点时间看一下吧




欢迎光临 FineUI 官方论坛 (https://fineui.com/bbs/) Powered by Discuz! X3.4