-1
    String start_cd;
    String end_cd;
    opencon();

    SqlCommand res = new SqlCommand("SELECT ID,'" + start_cd + "','" + end_cd + "' FROM Train_route_up WHERE " + start_cd + "!=0 or " + end_cd + "!=0", con);
    SqlDataAdapter sda_res = new SqlDataAdapter(res);
    DataTable dt_res = new DataTable();
    sda_res.Fill(dt_res);

    listBox1.DataSource=dt_res;
    listBox1.DisplayMember=" +start_cd+ ";
    //Train_route_up=  SQL table name
    //FOT=start_cd value(nvarchar)

listbox show System.Data.DataRowView (my sql table column name=FOT Data type=int)

sudhara
  • 45
  • 10
  • listBox1.DisplayMember="" +start_cd+ ""; – sudhara Feb 16 '14 at 05:59
  • Side note: the way you are constructing your SQL statement should be revised. See SQL INJECTION : ref: http://stackoverflow.com/questions/306668/are-parameters-really-enough-to-prevent-sql-injections – Hardrada Feb 17 '14 at 00:14

2 Answers2

1

try with

listBox1.DisplayMember= start_cd.Trim();
Damith
  • 62,401
  • 13
  • 102
  • 153
0

If the start_cd variable contains the name of the column that you want displayed then you assign the start_cd variable to the DisplayMember property, i.e.

listBox1.DisplayMember = start_cd;
jmcilhinney
  • 50,448
  • 5
  • 26
  • 46