protected void Button55_Click(object sender, EventArgs e)
{
ans1.Checked = false;
ans2.Checked = false;
ans3.Checked = false;
ans4.Checked = false;
string cs = WebConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
SqlConnection cn = new SqlConnection(cs);
cn.Open();
DropDownList2.SelectedIndex = 0;
SqlDataAdapter da3 = new SqlDataAdapter("select * from reasoning_en", cn);
da3.Fill(ds2, "reasoning_en");
i = Convert.ToInt32(ViewState["i"])-1;
SqlDataAdapter da = new SqlDataAdapter("select * from reasoning_en", cn);
da.Fill(ds, "reasoning_en");
ViewState["i"] = (int)ViewState["i"]-1;
DataSet ds6 = new DataSet();
SqlDataAdapter da6 = new SqlDataAdapter("select * from " + Label12.Text + "", cn);
da6.Fill(ds6, Label12.Text);
string m = ds6.Tables[0].Rows[i]["ans"].ToString().Trim();
if (m == ans1.Text)
{
ans1.Checked = true;
}
else if (m == ans2.Text)
{
ans2.Checked = true;
}
else if (m == ans3.Text)
{
ans3.Checked = true;
}
else if (m == ans4.Text)
{
ans4.Checked = true;
}
else
{
ans.Checked = true;
}
if (ds != null && (int)ViewState["i"] < ds.Tables[0].Rows.Count)
{
if (ds.Tables[0].Rows[i]["quesno"].ToString().Trim() == "1")
{
prev.Visible = false;
}
q0.Text = ds.Tables[0].Rows[i]["quesno"].ToString();
ques.Text = ds.Tables[0].Rows[i]["ques"].ToString();
ans1.Text = ds.Tables[0].Rows[i]["ans1"].ToString();
ans2.Text = ds.Tables[0].Rows[i]["ans2"].ToString();
ans3.Text = ds.Tables[0].Rows[i]["ans3"].ToString();
ans4.Text = ds.Tables[0].Rows[i]["ans4"].ToString();
ans.Text = ds.Tables[0].Rows[i]["ans5"].ToString();
String s = "select quesimg from reasoning_en where quesno='" + q0.Text + "'";
SqlCommand cmd = new SqlCommand(s, cn);
String path = Server.MapPath("~\\images\\");
SqlDataReader dr;
dr = cmd.ExecuteReader();
dr.Read();
Image1.Visible = true;//image control will now be visible.
Image1.ImageUrl = dr["quesimg"].ToString();//stores the image url to corresponding image contol and here Image1 is the id of the image control used
cn.Close();
}
else
{
}
cn.Close();
}