Set RadCheckbox programmatically

2 posts, 0 answers
  1. Bernhard
    Bernhard avatar
    8 posts
    Member since:
    Apr 2009

    Posted 30 Oct 2009 Link to this post

    In our database tables we have a field isDeleted. This indicates if a record is logically deleted. 

    There is a Delete-Button on the form. If the user presses this button, the flag should be set, then the data saved. After that the window is closed and the user gets back to the form with the list. The list is built upon a database view with the where-clause "where IsDeleted = 0".

    For editing the data I have a detail data form with a ObjectView. On the form there is a RadCheckbox-Control named cbIsDeleted.
    The control is bound via the IsChecked-Property to the persistent data.

    • If I check/uncheck the CheckBox with the mouse and save the data, the changed value is saved in the database.
    • If I want to do the same programmatically, on the GUI the Checkbox will be checked/ unchecked. But when I want to save the data - the changed value for the Checkbox wouldn't be stored in the database: 



    cbIsDeleted.ToggleState =   


    I tried also:


    cbIsDeleted.Checked = true

    What's wrong? Should I set some other properties?

    Thanks in advance

  2. Nick
    Nick avatar
    767 posts

    Posted 04 Nov 2009 Link to this post

    Hello Bernhard,

    We use the mechanism of .net framework about Binding properties.

    I tested your scenario with the following code snippet, and it seems that the checkbox is bound properly to the data table:

    DataTable t;
    private void Form6_Load(object sender, EventArgs e)
        this.radCheckBox1.IsThreeState = false;
        t = new DataTable();
        t.Columns.Add("A", typeof(bool));
        this.radCheckBox1.DataBindings.Add(new Binding("IsChecked", t, "A"));

    Checking and un-checking the checkbox affects the current row in the data table, and a change in the data table affects the checkbox.

    Do not hesitate to write me back if you have further questions.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top