protected void bindBatchList()//binding batches { ListToDataTable lsttodt = new ListToDataTable(); BatchService service = new BatchService(); var lst = service.GetBatchesData().Select(x => new { x.BatchName, x.ID }).ToList(); DataTable dt = lsttodt.ToDataTable(lst); if (dt != null && dt.Rows.Count > 0) { ddlBatchId.DataSource = dt; ddlBatchId.DataTextField = "BatchName"; ddlBatchId.DataValueField = "ID"; ddlBatchId.DataBind(); } else { ddlBatchId.DataBind(); } }