I have list box control where I am binding the values to the listbox
DataSet ds = new DataSet();
da.Fill(ds, "Employees");
ListBox1.DataSource = ds.Tables["Employees"].DefaultView;
ListBox1.SelectedIndex = 0;
ListBox1.DataTextField = "FirstName";
ListBox1.DataValueField = "StaffID";
ListBox1.Databind();
after select ing the value .
I have button once the user clicks this
protected void BtnClick(object sender, EventArgs e)
{
var selectedItems = (from item in listBox.Items.Cast<ListItem>() where item.Selected select item.Text).ToArray();
result.Text = "You selected: ";
result.Text += string.Join(",", selectedItems);
}
Right now I code inside the event gives me the selected vlaues name.
but I want to get the selected values index
ex
ID NAME
23 ram
34 tom
67 john
so if I select ram and john
in code behind I need to get these vales ID that is 23, 67
Hope my question is clear
Thank you
you need to iterate your listbox items like..