Pages

Sunday, October 3, 2010

Convert commaStringToIntArray Function





String strCategory = Convert.ToString(dt.Rows[0]["ProjectCategoriesAlert"]);

int[] category = clsBuilder.commaStringToIntArray(strCategory);

for (int i = 0; i < category.Length; i++)
{
cbl_Categories.Items[category[i] - 1].Selected = true;

}


----------------------------------------------------------

public static int[] commaStringToIntArray(string str)
{
String[] strArray = str.Split(',');
int[] intArray = new int[strArray.Length];
for (int i = 0; i < strArray.Length; i++)
{
intArray[i] = int.Parse(strArray[i]);
}
return intArray;
}

-----------------------------------------------------------------------
string str = string.Empty;
for (int i = 0; i < cbl_Categories.Items.Count; i++)
{
if (cbl_Categories.Items[i].Selected == true)
{
str += cbl_Categories.Items[i].Value + ",";
}

}






0 comments:

Post a Comment

 

CodeAddict.com | Copyright 2009 Tüm Haklar? Sakl?d?r | Free Blogger Templates by GoogleBoy Download Free Wordpress Templates. Unblock through unblock myspace proxy, Hillsongs by Guitar Song Chords