title: ERROR :- DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Optiont4'
body: <p>In <b>.aspx</b> page , I’ve taken Label Control in order to display question form the database,
  4 radio buttons in order to display four option related to a particular question, and last but not the least, I’ve used hidden field in which I will store answer of the particular question.
  And finally I’ve taken a Button Control, for which I’ve created the onclick event, on which I will perform the operation to generate score.</p>
  
  <p>In <b>.aspx.cs</b> page, on the onclick event of the button, , I’ve fetch the controls form the aspx page using code mentioned below, and further I’ve used if statement in order to see which radio button is active and have store the corresponding value in the varialbe “selans”, using this “selans”, I will compare it with the value of  hidden field in order to find whether checked radio button is the correct answer or not, it the answer is correct, i.e value in “selans” matches with the value in hidden field ( the actual answer) and the variable “count” ( initially initialized with value 0) increments accordingly, and all this code is placed in the “for loop” which will execute till the no. of controls in the GridView (you can relate it with the no. of question, as for every record GridView generates new control). </p>
  
  <p>But when I run it I am getting this error :-</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Optiont4'.
  
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
  Exception Details: System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Optiont4'.
  
  Source Error: 
  
  
  Line 115:            &lt;asp:RadioButton ID="rad2" runat="server" Text='&lt;%#Eval("Option2") %&gt;' GroupName="A" /&gt;
  Line 116:            &lt;asp:RadioButton ID="rad3" runat="server" Text='&lt;%#Eval("Option3") %&gt;' GroupName="A" /&gt;
  Line 117:            &lt;asp:RadioButton ID="rad4" runat="server" Text='&lt;%#Eval("Optiont4")%&gt;' GroupName="A" /&gt;
  Line 118:            &lt;asp:HiddenField ID="hf" runat="server" Value='&lt;%#Eval("CorrectAns")%&gt;' /&gt;
  Line 119:
  
  Source File: e:\Way2Success\Student\Examdemo.aspx    Line: 117 </code></pre>
  </div>
  </div>
  </p>
  
  <p>Here the error line number is 30 in .aspx page</p>
  
  <p>Have a look at my code. Show me were I am making mistaking and what is the solution.</p>
  
  <p><b>.aspx :- </b></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Examdemo.aspx.cs" Inherits="Student_Examdemo" %&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
    &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form2" runat="server"&gt;
          &lt;div&gt;
  &lt;div id="tabs"&gt;
      &lt;ul&gt;
          &lt;li&gt;&lt;a href="#tabs-1"&gt;Tab 1&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#tabs-2"&gt;Tab 2&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#tabs-3"&gt;Tab 3&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#tabs-4"&gt;Tab 4&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#tabs-5"&gt;Tab 5&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;div id="tabs-1"&gt;
          &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" &gt;
      &lt;Columns&gt;
          &lt;asp:TemplateField&gt;
              &lt;ItemTemplate&gt;
              &lt;asp:Label ID="Label1" runat="server" Text='&lt;%#Eval("Question") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;br /&gt;
              &lt;br /&gt;
              &lt;br /&gt;
             &lt;asp:RadioButton ID="rad1" runat="server" Text='&lt;%#Eval("Option1") %&gt;' GroupName="A" /&gt;
              &lt;asp:RadioButton ID="rad2" runat="server" Text='&lt;%#Eval("Option2") %&gt;' GroupName="A" /&gt;
              &lt;asp:RadioButton ID="rad3" runat="server" Text='&lt;%#Eval("Option3") %&gt;' GroupName="A" /&gt;
              &lt;asp:RadioButton ID="rad4" runat="server" Text='&lt;%#Eval("Option4") %&gt;' GroupName="A" /&gt;
              &lt;asp:HiddenField ID="hf" runat="server" Value='&lt;%#Eval("CorrectAns") %&gt;' /&gt;
  
          &lt;br /&gt;
          &lt;br /&gt;
  
                   &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
     
      &lt;/div&gt;
      &lt;div id="tabs-2"&gt;
          
  
          &lt;asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="false" &gt;
      &lt;Columns&gt;
          &lt;asp:TemplateField&gt;
              &lt;ItemTemplate&gt;
              &lt;asp:Label ID="Label1" runat="server" Text='&lt;%#Eval("Question") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;br /&gt;
              &lt;br /&gt;
              &lt;br /&gt;
             &lt;asp:RadioButton ID="rad1" runat="server" Text='&lt;%#Eval("Option1") %&gt;' GroupName="A" /&gt;
              &lt;asp:RadioButton ID="rad2" runat="server" Text='&lt;%#Eval("Option2") %&gt;' GroupName="A" /&gt;
              &lt;asp:RadioButton ID="rad3" runat="server" Text='&lt;%#Eval("Option3") %&gt;' GroupName="A" /&gt;
              &lt;asp:RadioButton ID="rad4" runat="server" Text='&lt;%#Eval("Optiont4")%&gt;' GroupName="A" /&gt;
              &lt;asp:HiddenField ID="hf" runat="server" Value='&lt;%#Eval("CorrectAns")%&gt;' /&gt;
  
          &lt;br /&gt;
          &lt;br /&gt;
  
                   &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  
      &lt;/div&gt;
      &lt;div id="tabs-3"&gt;
          Tab 3 Content
      &lt;/div&gt;
       &lt;div id="tabs-4"&gt;
          Tab 4 Content
      &lt;/div&gt;
       &lt;div id="tabs-5"&gt;
          Tab 5 Content
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;input type="button" id="btnPrevious" value="Previous" style = "display:none"/&gt;
  &lt;input type="button" id="btnNext" value="Next" /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
             
              &lt;asp:Button class="panelButton" runat="server" Text="Finish the exam" ClientIDMode="Static" OnClick="btn_Click" /&gt;
              &lt;br /&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><b> .aspx.cs :- </b></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Data.SqlClient;
  using System.Data;
  using System.Configuration;
  
  
  public partial class Student_Examdemo : System.Web.UI.Page
  {
  protected void Page_Load(object sender, EventArgs e)
  {
  if (!IsPostBack)
      {
          GridView1.DataSource = GetData("SELECT top 2 Question, Option1, Option2, Option3, Option4, CorrectAns, Explanation FROM Questions");
          GridView1.DataBind();
          GridView2.DataSource = GetData("SELECT top 2 Question, Option1, Option2, Option3, Option4, CorrectAns, Explanation FROM Questions WHERE SectionId=2");
          GridView2.DataBind();
  
  private DataSet GetData(string query)
  {
      string conString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
      SqlCommand cmd = new SqlCommand(query);
      using (SqlConnection con = new SqlConnection(conString))
      {
          using (SqlDataAdapter sda = new SqlDataAdapter())
          {
              cmd.Connection = con;
              sda.SelectCommand = cmd;
              using (DataSet ds = new DataSet())
              {
                  sda.Fill(ds);
                  return ds;
              }
          }
      }
  }
  
  protected void btn_Click(object sender, EventArgs e)
  {
  
              RadioButton r1, r2, r3, r4;
              HiddenField hdn;
              int count = 0;
              int neg = 0;
              int total;
              int totalf=0;
              int totals=0;
              int totalt;
              int totalfo;
              int totalfi;
              string selans = "-1";
              for (int i = 0; i &lt; GridView1.Rows.Count; i++)
              {
                  r1 = (RadioButton)GridView1.Rows[i].Cells[0].FindControl("rad1");
                  r2 = (RadioButton)GridView1.Rows[i].Cells[0].FindControl("rad2");
                  r3 = (RadioButton)GridView1.Rows[i].Cells[0].FindControl("rad3");
                  r4 = (RadioButton)GridView1.Rows[i].Cells[0].FindControl("rad4");
                  hdn = (HiddenField)GridView1.Rows[i].Cells[0].FindControl("hf");
                  if (r1.Checked)
                  {
                      selans = r1.Text;
                  }
                  else if (r2.Checked)
                  {
                      selans = r2.Text;
                  }
                  else if (r3.Checked)
                  {
                      selans = r3.Text;
                  }
                  else if (r4.Checked)
                  {
                      selans = r4.Text;
                  }
  
                  if (hdn.Value == selans)
                  {
                      count++;
                  }
                  else
                  {
                     neg--;
                  }
  
                  totalf = count + neg;
  
  
              }
  
      for (int i = 0; i &lt; GridView2.Rows.Count; i++)
      {
          r1 = (RadioButton)GridView2.Rows[i].Cells[0].FindControl("rad1");
          r2 = (RadioButton)GridView2.Rows[i].Cells[0].FindControl("rad2");
          r3 = (RadioButton)GridView2.Rows[i].Cells[0].FindControl("rad3");
          r4 = (RadioButton)GridView2.Rows[i].Cells[0].FindControl("rad4");
          hdn = (HiddenField)GridView2.Rows[i].Cells[0].FindControl("hf");
          if (r1.Checked)
          {
              selans = r1.Text;
          }
          else if (r2.Checked)
          {
              selans = r2.Text;
          }
          else if (r3.Checked)
          {
              selans = r3.Text;
          }
          else if (r4.Checked)
          {
              selans = r4.Text;
          }
  
          if (hdn.Value == selans)
          {
              count++;
          }
          else
          {
              neg--;
          }
  
          totals = count + neg;
  
      }
      total = totalf + totals;
      Session["score"] = total;
  
  }
  
  
  }
  </code></pre>