SelectedIndexChanged

3 posts, 1 answers
  1. Ron
    Ron avatar
    113 posts
    Member since:
    Apr 2011

    Posted 31 May 2011 Link to this post

    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. Answer
    Gimmik
    Gimmik avatar
    170 posts
    Member since:
    May 2011

    Posted 31 May 2011 Link to this post

    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
  3. Ron
    Ron avatar
    113 posts
    Member since:
    Apr 2011

    Posted 02 Jun 2011 Link to this post

    I really appreciate your assistance,

    Thank you.
Back to Top