i bound the list box with data table.display member is "Code" and value member is "ID".no w i want to retrieve the all item of list box.but it return me system.data.datarow.how can i get all item from ListBox in this Case
A:
You can use the DataRow
object to get the values of Code and ID columns:
foreach(var dr in ListBox1.Items)
{
var code = dr["Code"];
var id = dr["ID"];
}
TheVillageIdiot
2009-08-30 16:33:53
A:
foreach (object objObject in listBox1.Items)
{
System.Data.DataRowView objDataRowView = (DataRowView)objObject;
if (!(objDataRowView["Column_Name"].ToString() == "Search String")
{
Aray[i++]=objDataRowView["Column_Name"].ToString();
}
}
if Aray is a collection or Array of strings then it will have all the items of your search criteria in it or if you want to remove condition just remove if condition :D
Mobin
2009-08-30 17:04:11