in online examination system i am using a previous button and i want that at first question the previous button should hide i am using this code but this is not working tell me where i am wrong
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;
if (ds != null && (int)ViewState["i"] < ds.Tables[0].Rows.Count)
{
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();