将重点放在文本框上 [英] setting focus on textbox

查看:71
本文介绍了将重点放在文本框上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个组合框,在其SelectedIndexChange上,我在标签上显示所选项目的比率.
现在,在同一事件中,我想在标签获得所选项目的费率之后将焦点设置在文本框上,用户可以在其中输入数量".

Hey Everyone,

I have a combobox,on its SelectedIndexChange I am showing the rate of the selected item on a label.
Now on this same event I want to set the focus on a textbox after label has got the rate of the selected item, where user can input Quantity.

protected void combo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            RadComboBox combo = (RadComboBox)o;
            GridEditFormInsertItem insertItem = (GridEditFormInsertItem)combo.NamingContainer;
            Label lblRate = (Label)insertItem.FindControl("lblRateE");
            SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["conn"].ToString());
            SqlCommand cmd = new SqlCommand("select [Rate] FROM [tblProducts] where ProductName=@ProductName", conn);
            cmd.Parameters.Add(new SqlParameter("@ProductName", combo.SelectedValue));
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            if (ds.Tables[0].Rows.Count > 0)
            {
                lblRate.Text = ds.Tables[0].Rows[0].ItemArray.GetValue(0).ToString();
            }
        }



我想集中精力于txtQuantityE.
请有人帮忙.

谢谢
Amit



I want to set focus on txtQuantityE.
Someone help please.

Thanks
Amit

推荐答案

好吧-这应该很容易(除非我误解了您的问题).

tbFocusMe.Focus()插入您的if 条件.
Well - this should be easy (unless I''ve misunderstood your question).

Put tbFocusMe.Focus() insde your if condition.


文本框是否从组合框中移出?
Is the textbox out of combobox?
protected void combo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            //After all your code place
            txtQuantityE.Focus();
        }


这篇关于将重点放在文本框上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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