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

added item value goes to null after insertion?

4 Answers 70 Views
ListControl
This is a migrated thread and some comments may be shown as answers.
Giselle
Top achievements
Rank 1
Giselle asked on 08 Aug 2012, 03:42 PM
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!

4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 13 Aug 2012, 11:47 AM
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 >>
0
Giselle
Top achievements
Rank 1
answered on 13 Aug 2012, 02:06 PM
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.

0
Accepted
Peter
Telerik team
answered on 15 Aug 2012, 01:58 PM
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 >>
0
Giselle
Top achievements
Rank 1
answered on 28 Aug 2012, 05:35 PM
That worked. . . thanks Peter!
Tags
ListControl
Asked by
Giselle
Top achievements
Rank 1
Answers by
Peter
Telerik team
Giselle
Top achievements
Rank 1
Share this question
or