protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { voterDataset = vbl.GetVoterList(); GridViewVoterList.DataSource = voterDataset; GridViewVoterList.DataBind(); candidateDataset = vbl.GetCandidiateList(); GridViewCandidateList.DataSource = candidateDataset; GridViewCandidateList.DataBind(); } GridViewVotingResult.DataSource = vbl.GetVotingResult(); GridViewVotingResult.DataBind(); }
// GET api/values public List <VoterProperties> Get() { VoterBusinessLogic vbl = new VoterBusinessLogic(); DataSet ds = new DataSet(); ds = vbl.GetVoterList(); List <VoterProperties> voterList = new List <VoterProperties>(); foreach (DataRow dr in ds.Tables[0].Rows) { VoterProperties vp = new VoterProperties(); //foreach (DataColumn col in ds.Tables[0].Columns) //{ vp.VoterId = Convert.ToInt32(dr["Id"]); vp.FullName = dr["FullName"].ToString(); vp.Email = dr["Email"].ToString(); vp.PhoneNumber = dr["PhoneNumber"].ToString(); vp.Gender = dr["Gender"].ToString(); vp.DateOfBirth = Convert.ToDateTime(dr["DateOfBirth"]); //row.Add(col.ColumnName, dr[col]); //} voterList.Add(vp); } return(voterList); // return new string[] { "value1", "value2" }; }