Get property in repeating table by index

17/01/2014 14:24

When you get Xnode dropdown value, you get index, not displayname in code behind.

 

Dropdown has following repeating table as datasource

//Find display name by index in repeating table

 

  private string FindAllowedUserDisplayNameByIndex(string index)

        {

            //for AllowedUsers - Get user display name based on selected index

            string memberDisplayName = string.Empty;

            XPathNavigator root = MainDataSource.CreateNavigator();

            XPathNodeIterator iter = root.Select("/my:myFields/my:AllowedUsers", NamespaceManager);

            int rowsCount = iter.Count;

            for (int i = 1; i <= rowsCount; i++)

{

    if (XNode(("/my:myFields/my:AllowedUsers[" + i + "]//my:AllowedUserId")).Value == index)

            {

                    memberDisplayName = XNode(("/my:myFields/my:AllowedUsers[" + i + "]//my:AllowedUser")).Value;

            }

}

            return memberDisplayName;

        }