You're using integer division, so the result will be truncated.
Change your variables to
double
:
double correctAnswers = 0, incorrectAnswers = 0, totalQuestions = grdquestions.Rows.Count;
EDIT: You'll also need an
if (!IsPostBack) { ... }
test around the data-binding code in the
Page_Load
method. Otherwise, the user's selections will be overwritten every time, and none of the radiobuttons will be checked by the time the button click handler runs.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlCommand com = new SqlCommand("Select * from [Biology]", con);
SqlDataAdapter da = new SqlDataAdapter(com);
DataTable dt2 = new DataTable();
da.Fill(dt2);
grdquestions.DataSource = dt2;
grdquestions.DataBind();
}
}