Get List Box Selected Value from Listbox,
public static string GetListBoxSelectedValue(ListBox Listbox1)
{
string selectedItem = "";
if (Listbox1.Items.Count > 0) {
for (int i = 0; i < Listbox1.Items.Count; i++) {
if (Listbox1.Items[i].Selected) {
if (selectedItem == "") {
selectedItem = Listbox1.Items[i].Value;
break;
}
}
}
}
return selectedItem;
}Get List Box Selected Text,public static string GetListBoxSelectedText(ListBox Listbox1) {
string selectedItem = "";
if (Listbox1.Items.Count > 0) {
for (int i = 0; i < Listbox1.Items.Count; i++) {
if (Listbox1.Items[i].Selected) {
if (selectedItem == "") {
selectedItem = Listbox1.Items[i].Text;
break;
}
}
}
}
return selectedItem;
}