Click here to Skip to main content
15,922,427 members

Comments by asmaa elbattanony (Top 4 by date)

asmaa elbattanony 25-Jan-12 10:33am View    
Thanx Kishorekke
Your Solution Worked like a charm ^_^
asmaa elbattanony 27-Jul-11 8:42am View    
Just because its my first time to make a post in here and i made some mistakes now this means that I'm stupid???
OK well thank you for your (GREAT HELP)
I'm waiting for someone who can actually help me though
asmaa elbattanony 26-Jul-11 11:46am View    
Deleted
Shameel
Thank u for your help
i made something like your idea
but still nothing

here is my code(display method,next button and previous button actions)


////////////////////////DISPLAY METHOD///////////////////////////////
public void display()
{

DataRow dr=t.Rows[n];

Label3.Text=dr["q"].ToString();
RadioButtonList1.Items[0].Text = dr["a1"].ToString();
RadioButtonList1.Items[1].Text = dr["a2"].ToString();
RadioButtonList1.Items[2].Text = dr["a3"].ToString();
RadioButtonList1.Items[3].Text = dr["a4"].ToString();
Label4.Text = dr["c_ans"].ToString();
int index;
if (Session["selected"] != null)
{
index = RadioButtonList1.Items.IndexOf(RadioButtonList1.Items.FindByText(selected));
}
else
{
index = RadioButtonList1.Items.IndexOf(RadioButtonList1.Items.FindByText(dr["s_ans"].ToString()));
}
Response.Write(index);
RadioButtonList1.Items[index].Selected = true;

}

////////////////////////NEXT METHOD///////////////////////////////
protected void Button2_Click(object sender, EventArgs e)
{
try
{
Button1.Enabled = true;
Label4.Visible = false;

n = n + 1;
// selected = (string)Session["selected"];
string sql = "update questions set s_ans='" + selected + "' where q='" + Label3.Text + "'";
Response.Write(sql);
comm = new SqlCommand(sql, conn);
int x = comm.ExecuteNonQuery();

if (n >= t.Rows.Count - 1)
{

Button2.Enabled = false;
}
Session["selected"] = selected;
RadioButtonList1.SelectedIndex = -1;

Session["n"] = n;
display();

}
catch (Exception ex)
{
Label4.Visible = true;
Label4.Text = "Please Choose an answer "+ex.Message;
}
}

////////////////////////prev METHOD///////////////////////////////
protected void Button1_Click(object sender, EventArgs e)
{try
{

Button2.Enabled = true;
Label4.Visible = false;
// selected = (string)Session["selected"];
n = n - 1;
if (n == 0)
{
//n = 0;
Button1.Enabled = false;
}
string sql = "update questions set s_ans='" + selected + "' where q='" + Label3.Text + "'";
Response.Write(sql);
comm = new SqlCommand(sql, conn);
int x = comm.ExecuteNonQuery();

Session["selected"] = selected;
RadioButtonList1.SelectedIndex = -1;

Session["n"] = n;
display();



}
catch (Exception ex)
{
Label4.Visible = true;
Label4.Text = "Please Choose an answer "+ex.Message;
}
}
asmaa elbattanony 26-Jul-11 11:24am View    
Thank u for your reply
homework or not
I actually made an effort in this application
and i didn't ask to give me the full code
I'm having a problem in my code and I'm looking for help
Isn't this what this site is all about???
thank you again :)