protected void btnSubmit_Click(object sender, EventArgs e) { if (chkDeclaration.Checked) { DataAccessLayer DAL = new DataAccessLayer(); for (int index = 0; index < DataList1.Items.Count; index++) { //string lblRoleID = ((Label)DataList1.FindControl("RoleIDLabel")).Text; int RoleID = Convert.ToInt32(((Label)DataList1.Items[index].FindControl("lblRoleIDLabel")).Text); string lblPollID = ((Label)DataList1.Items[index].FindControl("lblPollIDLabel")).Text; int PollID = Convert.ToInt32(lblPollID); string RoleYear = ((Label)DataList1.Items[index].FindControl("lblRoleYear")).Text; string Candidate_Name = Convert.ToString(((RadioButtonList)DataList1.Items[index].FindControl("rbInsertVote")).SelectedValue); string PollName = Convert.ToString(((Label)DataList1.Items[index].FindControl("lblPollNameLabel")).Text); string PollRole = Convert.ToString(((Label)DataList1.Items[index].FindControl("lblPollRoleLabel")).Text); string PollQuestion = Convert.ToString(((Label)DataList1.Items[index].FindControl("lblPollQuestionLabel")).Text); DataAccessLayer.InsertResult(RoleID, PollID, RoleYear, Candidate_Name, PollName, PollRole, PollQuestion); lblMessage.Visible = true; lblMessage.Text = "Your VOTE has been captured. Thank you!"; lblMessage.ForeColor = System.Drawing.Color.Green; Response.Redirect("Candidate_Info.aspx"); } } else { lblMessage.Visible = true; lblMessage.Text = "Please sign the declaration to Vote"; lblMessage.ForeColor = System.Drawing.Color.Red; } }