String.remove does not work the way I was thinking it did. This was causing a runtime exception that did not show up until I did debugging, which is why TESTER's text wasn't getting updated.
I was able to fix my problem a different way.
Instead of building the string immediately and trying tricky string operations, instead I just put each string into a list and then removed the last item of the last at the end. Then once I had the perfected list, then I added it to the string.
In code it looks like this:
List<string> queryBuilder = new List<string>();
//add the seleted items to items in the list
foreach (ListItem li in MakeList.Items)
{
if (li.Selected)
{
queryBuilder.Add(li.Value);
queryBuilder.Add("' OR BV.MakeID = '");
//build the list of selected makes for later use
selectedMakes.Add(li.Value);
}
}
try
{
//remove the last ' AND BV.MakeID= '
queryBuilder.RemoveAt(queryBuilder.Count-1);
//add back the ' and the orderby
queryBuilder.Add("'");
queryBuilder.Add(" ORDER BY [ModelName]");
//build the string
foreach(string s in queryBuilder){
newQuery+= s;
}
//debug for visibilty
TESTER.Text =newQuery;