Mahmoud Omar

Mahmoud Omar

  • NA
  • 62
  • 496

Get data from database, pass this data with grid columns?

Oct 11 2016 5:56 AM
i want Get values or data from database and pass every columns from database with columns that i add it in gridview.
 
i used this cold but this code don't  give me what i want :-
 con.Open(); SqlCommand cmd = new SqlCommand("Select code,Name,Salary,desc FROM tableName", con); SqlDataReader dr = cmd.ExecuteReader(); GridView1.DataSource = dr; GridView1.DataBind();         con.Close();
 How i cgange this code and pass this columns(code ,Name ,salary ,Desc) to the columns that i add it in gridview 

Answers (1)