Repopulating data on button click

3 posts, 0 answers
  1. Nicklas
    Nicklas avatar
    16 posts
    Member since:
    Mar 2012

    Posted 06 Aug 2013 Link to this post


    I am populating my data in my RadComboBox by using a ObjectDataSource, everything works fine.

    Now when I want to delete items from the RadCombobox and the database it doesnt work. 

    It gets removed from the database successfully, but it still remains in my combobox, even though I refresh the page it still remains, The only thing that works is to shutdown the whole debugging and start it again, then it repopulates the data from the database.

    Any idea what to do to repopulate the data? Ive tried doing a full post back, with no luck. I have searched forum and tried several propsals with no luck.

    I am starting to think its because its saved in cached or in memory somehow? (clientsided)

    Appreciate any help!
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Aug 2013 Link to this post

    Hi Nicklas,

    Please have a look at the following C# code snippet that I tried for deleting items from both RadComboBox and database.

    protected void RadButton1_Click(object sender, EventArgs e)
        String  connstring = WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
        SqlConnection connection = new SqlConnection(connstring);
        string sqlStatement = "DELETE FROM City";
            SqlCommand cmd = new SqlCommand(sqlStatement, connection);
            cmd.CommandType = CommandType.Text;

  3. Nicklas
    Nicklas avatar
    16 posts
    Member since:
    Mar 2012

    Posted 07 Aug 2013 Link to this post

    Did some changes and managed to get it to work, I now populate my data by using 2 comboboxes, the latter is filtered by the first, by adding a event listener on the first combobox, so whenever something is changed in the first combobox, the latter combobox will get filtered.

    protected void ComboBox_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
                ComboBox.DataSource = //dataset here / datatable
                ComboBox.DataTextField = "column you wish to show in combobox";
    //Then Finally clearing the combobox text or as in my case I decided to select the first item in the dataset instead.
    ComboBox.Items[0].Selected = true;
Back to Top