Click here to Skip to main content
15,940,271 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();
            }
        }


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

Thanks
Amit
Posted
Updated 13-Oct-10 21:36pm
v2
Comments
Dalek Dave 14-Oct-10 3:36am    
Edited for Grammar and Readability.

Well - this should be easy (unless I've misunderstood your question).

Put tbFocusMe.Focus() insde your if condition.
 
Share this answer
 
Is the textbox out of combobox?
protected void combo_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            //After all your code place
            txtQuantityE.Focus();
        }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900