title: Index and length must refer to a location within the string. Parameter name: length exception
body: <p>am getting the above exception while swaping Items in the list(lstRoutePriority).PFB my code</p>
  
  <pre><code>if (lstRoutePriority.SelectedIndex &gt; 0)
  {
     //Swap the two items 
     idTemp = (ItemData)lstRoutePriority.Items[lstRoutePriority.SelectedIndex];
     lstRoutePriority.Items[lstRoutePriority.SelectedIndex] = 
     lstRoutePriority.Items[lstRoutePriority.SelectedIndex-1];
     lstRoutePriority.Items[lstRoutePriority.SelectedIndex-1] = idTemp;
  }
  </code></pre>
  
  <p>can someone tell me how to fix this?
  Thanks in advance</p>