title: trouble splitting strings - asp.net VB
body: <p>I have a big database where each row has a unique document code and then a price per quantity and per member/non member. i.e. each quantity has 2 prices a member price and a non member price. (Would post a pic but apparently i don't have enough reputation).</p>
  
  <p>Anyway i rip the values from the database using a select command that looks like this:</p>
  
  <pre><code>&lt;asp:SqlDataSource id="sds_docReader" ConnectionString="&lt;%$ ConnectionStrings:constr %&gt;"
   runat="server" SelectCommand="
   SELECT '--Please Select--' AS fld_DocCode, '' AS myValue,  0 as myorder
   UNION
   SELECT fld_DocCode, (CAST([fld_MemCost25] AS varchar(10)) + '^^' + CAST([fld_NonMemCost25] AS varchar(10)) + '@@' + CAST([fld_MemCost50] AS varchar(10)) + '^^' + CAST([fld_NonMemCost50] AS varchar(10)) + '@@' + CAST([fld_MemCost75] AS varchar(10)) + '^^' + CAST([fld_NonMemCost75] AS varchar(10)) + '@@' + CAST([fld_MemCost100] AS varchar(10)) + '^^' + CAST([fld_NonMemCost100] AS varchar(10)) + '@@' + CAST([fld_MemCost200] AS varchar(10)) + '^^' + CAST([fld_NonMemCost200] AS varchar(10)) + '@@' + CAST([fld_MemCost300] AS varchar(10)) + '^^' + CAST([fld_NonMemCost300] AS varchar(10)) + '@@' + CAST([fld_MemCost400] AS varchar(10)) + '^^' + CAST([fld_NonMemCost400] AS varchar(10)) + '@@' + CAST([fld_MemCost500] AS varchar(10)) + '^^' + CAST([fld_NonMemCost500] AS varchar(10))) AS myValue, 
   1 as myorder
   FROM [tbl_DocData]
   ORDER BY myorder, fld_DocCode " /&gt;
  </code></pre>
  
  <p>and shove it into the value field of my dropdown list to get something like this on the page back-end:</p>
  
  <p><code>value="60.50^^75.50@@121.00^^151.00@@135.75^^181.50@@181.00^^242.00@@362.00^^484.00@@453.00^^633.00@@484.00^^724.00@@605.00^^905.00"</code></p>
  
  <p>So this is what i'm trying to do at the moment:</p>
  
  <p>Split the value field at every @@ to get an array of price pairs:
  <code>"[member_price]^^[non_memberprice]"</code></p>
  
  <p>Using the <code>.selectedindex</code> from a quantity drop down list i pull out the right pair from the array I've just made.</p>
  
  <p>then the final step is to split the price pair array from <code>price1^^price2</code> into an array of <code>price1, price2</code></p>
  
  <p>then depending on whether they have checked a box to show they are a member or not i'll take either the 0 index member of the array (what was on the left hand side of the price pair) for the member price, or the 1 index member of the array for the non member price.</p>
  
  <p>this is the code i'm trying to use to do the above:</p>
  
  <pre><code>Protected Sub btn_Calc_Command(sender As Object, e As System.Web.UI.WebControls.CommandEventArgs)
      'get the left side of the price pairs (members)
      Dim side As Integer = 0
  
      If cb_CCTAMember.Checked = True Then
          'get the right side (non members)
          side = 1
      End If
  
  
      If AC1.SelectedItem.Text &lt;&gt; "--Please Select--" And Quan1.SelectedItem.Text &lt;&gt; "0" Then
          'we calculate
  
          'get right hidden value string
          Dim costs As String = AC1.SelectedItem.Value
  
          'split by quantity to get price pairs
          Dim costarray As Array
          costarray = costs.Split("@@")
  
          'get right pair
          Dim pair As String = costarray(Quan1.SelectedIndex - 1)
  
          'split the pair
          Dim sprice As Array
          sprice = pair.Split("^^")
  
          'show cost as the right value
          Cost1.Value = sprice(side)
  
      End If
  End Sub
  </code></pre>
  
  <p>So at the moment it works, but only for every other value. I.e. it will work for 25 but not for 50, will work for 75 but not for 100.</p>
  
  <p>Am i missing anything obvious/ any ideas on what could be going wrong/ thoughts on alternative ways to get the same result.</p>
  
  <p>cheers</p>