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

reset radcombobox after SelectedIndexChanged event?

1 Answer 309 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Henry
Top achievements
Rank 1
Henry asked on 11 Apr 2012, 04:47 AM
I have a radcombobox and radgrid in the page, the combobox is set to EnableLoadOnDemand and AutoPostBack, EmptyMessage="Please make a selection". when user makes selection, SelectedIndexChanged event fired automatically and populates the radgrid, all worked fine.

now the requirement is that after it populates the radgrid in the SelectedIndexChanged event, I need to reset to radcombobox to the original status that showing the EmptyMessage instead of showing the current selection. I tried to clear the items and call databind, but it throws exceptions.

how can I to do that?

thanks.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Apr 2012, 05:49 AM
Hi Henry,

Please take a look into the following code snippet I tried and worked as expected.

ASPX:
<telerik:RadComboBox ID="RadComboBox1" runat="server" EnableLoadOnDemand="true" AutoPostBack="true"
 
onselectedindexchanged="RadComboBox1_SelectedIndexChanged" EmptyMessage="select" >
    <Items>
        <telerik:RadComboBoxItem Text="1" Value="1" />
        <telerik:RadComboBoxItem Text="2" Value="2" />
        <telerik:RadComboBoxItem Text="3" Value="3" />
    </Items>
</telerik:RadComboBox>
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="true"
</telerik:RadGrid>

C#:
public void BindGrid()
{
    SqlConnection con1 = new  SqlConnection(WebConfigurationManager.ConnectionStrings["NorthwindConnectionString3"].ConnectionString);
    SqlCommand cmd = new SqlCommand("SELECT  * FROM [Customers]", con1);
    SqlDataAdapter ad = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    ad.Fill(ds);
    RadGrid1.DataSource = ds;
}
protected void RadComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
{
    BindGrid();
    RadGrid1.Rebind();
    RadComboBox1.ClearSelection();
}

Regards,
Shinu.
Tags
Grid
Asked by
Henry
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or