public List <clsDesignation> GetDesignationData() { DataTable dt = new DataTable(); //SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connection"].ConnectionString); SqlCommand cmd = new SqlCommand("getDesignationDetails", con); cmd.CommandType = CommandType.StoredProcedure; con.Open(); using (SqlDataAdapter ad = new SqlDataAdapter(cmd)) { ad.Fill(dt); } con.Close(); List <clsDesignation> liDes = new List <clsDesignation>(); if (dt.Rows.Count >= 1) { foreach (DataRow row in dt.Rows) { clsDesignation desig = new clsDesignation(); desig.id = Convert.ToInt32(row["id"].ToString()); desig.Designation_Name = row["DesignationName"].ToString(); liDes.Add(desig); } } return(liDes); }