I solved my problem... A simple mistake by me that is to interchange foreach loop and while loop.
Previously foreach loop is written first and then while loop to read the data from the database.
foreach (RepeaterItem rp in QuestionRepeater.Items)
{
while (dr.Read())
{
if (rp.ItemType == ListItemType.Item || rp.ItemType == ListItemType.AlternatingItem)
{
a.QuestionNumber = Convert.ToInt32(dr["QuestionNumber"]);
var rb1 = rp.FindControl("rb1") as RadioButton;
var rb2 = rp.FindControl("rb2") as RadioButton;
var rb3 = rp.FindControl("rb3") as RadioButton;
var rb4 = rp.FindControl("rb4") as RadioButton;
}
}
}
For a sample i just changed the order while loop top and foreach loop down that means reading from the database and then getting questions and options in correct way
while (dr.Read())
{
foreach (RepeaterItem rp in QuestionRepeater.Items)
{
if (rp.ItemType == ListItemType.Item || rp.ItemType == ListItemType.AlternatingItem)
{
a.QuestionNumber = Convert.ToInt32(dr["QuestionNumber"]);
var rb1 = rp.FindControl("rb1") as RadioButton;
var rb2 = rp.FindControl("rb2") as RadioButton;
var rb3 = rp.FindControl("rb3") as RadioButton;
var rb4 = rp.FindControl("rb4") as RadioButton;
}
}
}