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

Bind Values to RadCombo Box Dynamically when we perform “SelectedIndexChanged” event.

3 Answers 141 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ranganath
Top achievements
Rank 1
Ranganath asked on 21 Jul 2008, 01:48 PM

Hi,

I am trying to Bind Values to RadCombo Box Dynamically when we perform “SelectedIndexChanged” event.

But I want to perform this operation without postback.

I taken one small Example as like

<telerik:RadAjaxManager ID="RadAjaxManager2" DefaultLoadingPanelID="RadAjaxLoadingPanel1"

        runat="server">

        <AjaxSettings>

            <telerik:AjaxSetting AjaxControlID="RadComboBox1">

                <UpdatedControls>

                    <telerik:AjaxUpdatedControl ControlID="RadComboBox1" />

                </UpdatedControls>

            </telerik:AjaxSetting>

        </AjaxSettings>

    </telerik:RadAjaxManager>

    

   

    <table cellpadding="0" cellspacing="0" width="100%" border="1" style="border-color: Green">

        <tr>

           

            <td>

                <telerik:RadComboBox ID="RadComboBox1" Runat="server"

                    onselectedindexchanged="RadComboBox1_SelectedIndexChanged">

                </telerik:RadComboBox>

            </td>

        </tr>

       

    </table>

protected void Page_Load(object sender, EventArgs e)

    {

        if (!IsPostBack)

        {

            RadComboBox1.Items.Add(new RadComboBoxItem("One"));

            RadComboBox1.Items.Add(new RadComboBoxItem("Two"));

            RadComboBox1.Items.Add(new RadComboBoxItem("Three"));

            this.Label1.Visible = false;

        }  

 

       

    }

protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)

    {

        // Put a breakpoint here  

        RadAjaxPanel1.ResponseScripts.Add("alert('OnChangeEventWas Handled')");

        Label1.Visible = true;

 

    }

But I am nt able to do this …pls give some exaples on this.

3 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 21 Jul 2008, 02:59 PM
Hello Ranganath,

I am not sure I understand the problem completely. Is the problem that the server event SelectedIndexChanged never fires? This is why the AutoPostBack property of RadComboBox is turned off. I suggest you set the AutoPostBack to true. If this does not help you, please provide us with steps to reproduce the problem.

Regards,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ranganath
Top achievements
Rank 1
answered on 21 Jul 2008, 05:16 PM

Hi,
Thanks for help. I tried with u r Solution,but I am able to perform “
RadComboBox1_SelectedIndexChanged” Event, But I am nt getting the Required O/P.

 

Here I am sending the Example which I implemented ….

<div>

        <telerik:RadAjaxManager ID="RadAjaxManager1" DefaultLoadingPanelID="RadAjaxLoadingPanel1"

            runat="server">

            <AjaxSettings>

                <telerik:AjaxSetting AjaxControlID="RadComboBox1">

                    <UpdatedControls>

                        <telerik:AjaxUpdatedControl ControlID="RadComboBox1" />

                    </UpdatedControls>

                </telerik:AjaxSetting>

            </AjaxSettings>

        </telerik:RadAjaxManager>

        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px"

            Width="75px">

            <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>'

                style="border: 0px;" />

        </telerik:RadAjaxLoadingPanel>

        <radC:RadComboBox ID="RadComboBox1" runat="server" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"

            AutoPostBack="True">

        </radC:RadComboBox>

        <%--<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />--%>

        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></div>

 

protected void Page_Load(object sender, EventArgs e)

    {

        if (!IsPostBack)

        {

            RadComboBox1.Items.Add(new Telerik.WebControls.RadComboBoxItem("One"));

            RadComboBox1.Items.Add(new Telerik.WebControls.RadComboBoxItem("Two"));

            RadComboBox1.Items.Add(new Telerik.WebControls.RadComboBoxItem("Three"));

            Label1.Visible = false;

        }

    }

 

protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)

    {

        Label1.Visible = true;

        //int i = 0;

    }

0
Rosi
Telerik team
answered on 22 Jul 2008, 12:07 PM
Hi Ranganath,

I suggest you add the Label1 control to the updated controls to the definition of RadAjaxManager:

  <telerik:RadAjaxManager ID="RadAjaxManager1" DefaultLoadingPanelID="RadAjaxLoadingPanel1"   
 
            runat="server">   
 
            <AjaxSettings>   
 
                <telerik:AjaxSetting AjaxControlID="RadComboBox1">   
 
                    <UpdatedControls>   
 
                        <telerik:AjaxUpdatedControl ControlID="RadComboBox1" />   
                        <telerik:AjaxUpdatedControl ControlID="Label1" />   
                    </UpdatedControls>   
 
                </telerik:AjaxSetting>   
 
            </AjaxSettings>   
 
        </telerik:RadAjaxManager>   
 
 


Regards,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox
Asked by
Ranganath
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Ranganath
Top achievements
Rank 1
Share this question
or