I have a string of itemIDs, and I want the gridview to use this parameter and get me the rest of the details from the item table. The problem i think is itemIDs is in varchar format and the db itemID is in int format.
because of this when the gridview page that display the item details loads i get the following error. Well i think this is the cause for the error, correct me if im wrong!
Conversion failed when converting the varchar value ' + itemIDs + ' to data type int.
the sql query used is:
SELECT ItemID, Name, RelDate, Price, Status FROM item_k WHERE (ItemID IN (' + itemIDs + '))
itemIDs string contains values like "3,16,8"
how can I convert it to the int format? and where to place the conversion? in the sql statement?
thanks
//edit 2
ArrayList tmpArrayList = new ArrayList();
tmpArrayList = (ArrayList)Session["array"];
string itemIDs = string.Empty;
foreach (object itemID in tmpArrayList)
{
itemIDs += itemID.ToString() + ',';
}
itemIDs = itemIDs.Substring(0, itemIDs.Length - 1);
Is there any simple way to solve this problem?