Anita Srivastav

Anita Srivastav

  • NA
  • 21
  • 15k

previous button is not working correctly

Nov 28 2013 12:25 AM

hello frnd i am workin on reply button code  here all the function is working correctly all my sql databse's data is shoing previously when i click but when data is empty i want that it shoud open a new page/tab here i am using tab but if u want to open a page welcome  my previous button code is here guide me where i am wrong

string cs = WebConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
SqlConnection cn = new SqlConnection(cs);
cn.Open();
j = Convert.ToInt32(ViewState["j"]) - 1;
SqlDataAdapter da5 = new SqlDataAdapter("select * from math_en", cn);
da5.Fill(ds5, "math_en");
ViewState["j"] = (int)ViewState["j"] - 1;

if (ds5 != null && (int)ViewState["j"] < ds5.Tables[0].Rows.Count)
{

q1.Text = ds5.Tables[0].Rows[j]["quesno"].ToString();
ques0.Text = ds5.Tables[0].Rows[j]["ques"].ToString();
ans5.Text = ds5.Tables[0].Rows[j]["ans1"].ToString();
ans6.Text = ds5.Tables[0].Rows[j]["ans2"].ToString();
ans7.Text = ds5.Tables[0].Rows[j]["ans3"].ToString();
ans8.Text = ds5.Tables[0].Rows[j]["ans4"].ToString();
ans9.Text = ds5.Tables[0].Rows[j]["ans5"].ToString();
String s2 = "select quesimg from reasoning_en where quesno='" + q1.Text + "'";
SqlCommand cmd = new SqlCommand(s2, 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
{
TabContainer1.ActiveTab = TabContainer1.Tabs[1];
}

cn.Close();


Answers (1)