I got a problem with ListBox.Selecte dItem
When I bound a listbox to a database, and try to convert listbox.selecte ditem to string, it returns me "System.Data.Da taRowView".
And later I try to use listbox.text, it works.
Does anyone know what's wrong?
Thank you
When I bound a listbox to a database, and try to convert listbox.selecte ditem to string, it returns me "System.Data.Da taRowView".
And later I try to use listbox.text, it works.
Does anyone know what's wrong?
Code:
private DataSet ListDataBinding()
{
SqlConnection cn = new SqlConnection();
SqlDataAdapter da_returnDS;
DataSet returnDS_ds = new DataSet();
string SQLStr = "";
cn.ConnectionString = MMMP.MainDialogForm.connection_string;
cn.Open();
SQLStr = "Select distinct Date_Accept from Work_Order_History order by Date_Accept";
da_returnDS = new SqlDataAdapter(SQLStr, cn);
da_returnDS.Fill(returnDS_ds, "DistinctMember");
cn.Close();
return returnDS_ds;
}
private void Sch_History_Frm_Load(object sender, EventArgs e)
{
DataSet dS_Date = ListDataBinding();
lstb_Date.DataSource = dS_Date;
lstb_Date.DisplayMember = "DistinctMember.Date_Accept";
}
private void lstb_Date_SelectedIndexChanged(object sender, EventArgs e)
{
if (lstb_Date.SelectedIndex != -1)
{
string hist_Date = Convert.ToString(lstb_Date.SelectedValue);
}
}