added item value goes to null after insertion?

5 posts, 1 answers
  1. Giselle
    Giselle avatar
    7 posts
    Member since:
    Mar 2011

    Posted 08 Aug 2012 Link to this post

    I'm trying to create a data transfer control between 2 radlist controls, but when I transfer/move/insert the new item, the value sets itself to null after adding the item, even though I've specified it.
    Can anyone please tell me what I'm doing wrong?

    My two radlists are lstLeft and lstRight. My code looks like this:
    Telerik.WinControls.UI.RadListDataItem item = new Telerik.WinControls.UI.RadListDataItem(lstRight.SelectedItem.Text, new Guid(lstRight.SelectedItem.Value.ToString()));
    lstLeft.Items.Add(item);
    lstRight.Items.Remove(lstRight.SelectedItem);
    lstLeft.Refresh();
    lstRight.Refresh();

    when I set a break point on "lstRight.Items.Remove(lstRight.SelectedItem);" the value for the item added in lstLeft is null. But if I check the value after creating the item, the value is there.

    Help!
  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 13 Aug 2012 Link to this post

    Hello Giselle,

    Thank you for writing.

    You should use the RadListDateItem's Text property instead of the Value property. The Value property is valid only for data-bound RadListDateItems and in your code the Value is null. Please, refer to the attached project.

    A bit off topic, I would like to remind you that your subscription package has expired, which means that you are no longer entitled for our support services. I would highly recommend upgrading your license to the latest version in order to continue getting product updates and uninterrupted support services. Please, contact sales@telerik.com or visit your account for your upgrading options.

    I hope this helps.

    Regards,
    Peter
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Giselle
    Giselle avatar
    7 posts
    Member since:
    Mar 2011

    Posted 13 Aug 2012 Link to this post

    Hi Peter,

    Thank you for your reply. I'll go ahead and let the office know that our subscription has expired. Thanks for the heads up!

    Is there any way to move the value over though with the item? For our project I'd have to re-retrieve the value afterwards, so it would really work best if the value was already there.

  5. Answer
    Peter
    Admin
    Peter avatar
    1148 posts

    Posted 15 Aug 2012 Link to this post

    Hi,

    You are welcome. I am letting you know because otherwise you will not be able to receive support from Telerik representatives. 

    In regards to your question, the Value property will have value in case that the RadListControl is data-bound and the ValueMember property is specified.

    If you are using the control in data-bound mode, you should not manipulate the items directly (e.g. you should not call the Add method of the Items collection). Instead, in data-bound mode you should manipulate the data source.

    I hope this helps.

    Regards,
    Peter
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  6. Giselle
    Giselle avatar
    7 posts
    Member since:
    Mar 2011

    Posted 28 Aug 2012 Link to this post

    That worked. . . thanks Peter!
Back to Top
UI for WinForms is Visual Studio 2017 Ready