This article tries to provide a new alternative approach to solve the economic dispatch (ED) problem in a smart grid system. Such a problem has been widely studied recently with several advanced numerical optimization algorithms being proposed. However, most of these numerical algorithms may suffer from high computational cost for on-line optimization. In this article, we aim to address this problem by proposing a learning-based optimization strategy. The key idea is to regard the optimization strategy of the ED problem as an unknown mapping relationship. With the help of traditional ED optimization algorithms to obtain the ground truth, we employ a deep neural network (DNN) to learn the ED optimization strategy and use it for online ED. In particular, our main contribution in this article is to theoretically show that one popular ED algorithm, i.e., <inline-formula xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink"> <tex-math notation="LaTeX">$\lambda $ </tex-math></inline-formula> -iteration algorithm, can be accurately approximated by a well-constructed DNN with finite network size. Moreover, dynamic units status of dispatchable generators is also considered and can be well solved by our proposed approach. Furthermore, several simulation case studies implemented on a 3-unit power system and an IEEE-30 bus power system validate the effectiveness of our proposed method.