This is a migrated thread and some comments may be shown as answers.

SelectedIndexChanged

2 Answers 36 Views
This is a migrated thread and some comments may be shown as answers.
Ron
Top achievements
Rank 1
Ron asked on 31 May 2011, 03:08 PM
Hi,

I'm using a rad combo box within a rad grid and the first column of the grid is the rad combo box. Can you tell me if it's possible that on selected index changed if I can set the text property for a label or text box control outside of the grid? I'm not looking to set the text property for any controls within the grid but out side the grid. I've tried the following with no results. 
protected void RadComboBox1_OnSelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
   {
       lblSubtotal.Text = "Mytest";
   }

Thanks,
Ron.

2 Answers, 1 is accepted

Sort by
0
Accepted
Gimmik
Top achievements
Rank 1
answered on 31 May 2011, 04:18 PM
Hi Ron,

I had the same issue a while back. It can be annoying to get to work the first time - then it's the easiest thing in the World. I can't be sure without seeing your ASPX, but I'm guessing that your RadComboBox isn't posting back to the server after an item is selected. Until a postback occurs, you won't see whether the label has been updated server-side.

To that end, you can setup your RadComboBox like this:
<telerik:RadComboBox ID="RadComboBox1" runat="server" OnSelectedIndexChanged="RadComboBox1_OnSelectedIndexChanged" AutoPostBack="true">

However, why go through a postback if you don't have to? This is exactly the case that JavaScript was intended to solve. So, a superior solution is to change the label client-side and not postback the whole grid unnecessarily.

You can setup your RadComboBox like this:
<telerik:RadComboBox ID="RadComboBox1" runat="server" OnClientSelectedIndexChanged="RadComboBox1_OnSelectedIndexChanged">

and include the following JavaScript function.
function RadComboBox1_OnSelectedIndexChanged(sender, args) {
 
    var label = document.getElementById("Label1");
    label.innerHTML = "Awesome Text";
}

JavaScript is your friend!

Hope this helps!
-Gimmik
0
Ron
Top achievements
Rank 1
answered on 02 Jun 2011, 04:28 PM
I really appreciate your assistance,

Thank you.
Asked by
Ron
Top achievements
Rank 1
Answers by
Gimmik
Top achievements
Rank 1
Ron
Top achievements
Rank 1
Share this question
or