public static class ExtendMethods { /// <summary> /// 绑定列表控件 /// </summary> /// <param name="listControl">列表控件</param> /// <param name="dt">数据表</param> public static void BindListControl(this ListControl listControl, DataTable dt) { if (dt != null) { listControl.DataSource = dt; listControl.DataTextField = dt.Columns[1].Caption; listControl.DataValueField = dt.Columns[0].Caption; listControl.DataBind(); } } }