0
votes

I have a RadGrid with 3 columns:
1) ID
2) Account Code (Dropdown in Edit and Add mode)
3) Description

In Edit & Add mode, Only "Account Code" column is visible and it is a Dropdown. This Dropdown is bind with 2 values together (Account Code + Description) So when user "Add" or "Edit" in RadGrid, Account Code dropdown appears with combined value of (Account code + Description)

Ex: 1420.121620 - Acc Dep-IT Hardware Lease & HP
       1420.133192 - Acc Dep-IT HP2
       (account code - description)

Now my requirement is: when user selects any item from this Dropdown and then Click on "tick" button of RadGrid to Add new record or "Edit" button to Edit record, 'Account Code' should save in RadGrid's "Account code column" and 'Description' should save in RadGrid's "Description column", and visible inside RadGrid.

I tried using Split function but couldn't succeed.

Please reply how to achieve it. I am very new in Telerik controls.
Thanks in advance.

1

1 Answers

0
votes

If you can get the selected value in a string than you can separate the accountNumber and accountName like this.

string selectedValue = "1420.121620 - Acc Dep-IT Hardware Lease & HP";
string accNum  =  selectedValue.Substring(0, selectedValue.IndexOf('-')).Trim();
string accName = selectedValue.Substring(selectedValue.IndexOf('-') + 1).Trim();

To remove spaces from start or end use .Trim() method.