Hello,
I am using update panel in my design. When i clicking the save nad next button i updating the question and i am also updating the xml which i created on page load by using a UpdateXml() which i created. But when i calling a UpdateXml() (as i mentioned in my code) function on click it's not updating question just updating the xml. While when i remove this calling it's work updating question . Can you tell me what is the problem with this ? Why is it behaving like this.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div id="question_panel" class="sub_panel">
<asp:Panel ID="Question_panel_main" CssClass="Question_panel_main" runat="server">
<table>
<tr>
<td style="font-family: 'Arial Unicode MS'">
<asp:Label ID="Question_No_label" runat="server" Text="Label"></asp:Label></td>
</tr>
<tr>
<td style="height: 20px;"></td>
</tr>
<tr>
<td>
<asp:Label ID="Question_detail" runat="server" Text="Label"></asp:Label></td>
</tr>
<tr>
<td>
<ol>
<li>
<asp:Label ID="Option_1" runat="server" Text="Label"></asp:Label>
</li>
<li>
<asp:Label ID="Option_2" runat="server" Text="Label"></asp:Label>
</li>
<li>
<asp:Label ID="Option_3" runat="server" Text="Label"></asp:Label>
</li>
<li>
<asp:Label ID="Option_4" runat="server" Text="Label"></asp:Label>
</li>
</ol>
</td>
</tr>
</table>
<div id="button-matrix-section">
<table>
<tr>
<td>
<img src="image/skip.png" />
</td>
<td>
<label>
  Skipped Questions</label>
</td>
<td>:
</td>
<td>
<asp:Label ID="skipped_ques_no_label" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td style="height: 2px"></td>
</tr>
<tr>
<td>
<img src="image/attempt.png" />
</td>
<td>
<label>
  Attempted Questions</label>
</td>
<td>:
</td>
<td>
<asp:Label ID="attempted_ques_no_label" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td style="height: 2px"></td>
</tr>
<tr>
<td>
<img src="image/not_attempt.png" />
</td>
<td>
<label>
  Not Attempted Questions</label>
</td>
<td>:
</td>
<td>
<asp:Label ID="not_attempted_ques_no_label" runat="server" Text="Label"></asp:Label>
</td>
</tr>
</table>
<asp:Panel ID="btn_matrix" CssClass="button_matrix_pannel" runat="server">
<div>
</div>
</asp:Panel>
</div>
<div id="option_select_div">
<div style="margin: 15px 0 0 10px;">
<img src="image/arrow.png" alt="" />
</div>
<div>
<asp:RadioButtonList ID="Radio_Button_Option" runat="server" CellPadding="10" CellSpacing="5" RepeatDirection="Horizontal">
<asp:ListItem Value="1">(A)</asp:ListItem>
<asp:ListItem Value="2">(B)</asp:ListItem>
<asp:ListItem Value="3">(C)</asp:ListItem>
<asp:ListItem Value="4">(D)</asp:ListItem>
</asp:RadioButtonList>
</div>
</div>
</asp:Panel>
<div id="more_btn">
<table style="outline: 0px;">
<tr>
<td style="width: 10px"></td>
<td>
<asp:ImageButton ID="button_previous" CssClass="image_btn" runat="server" ImageUrl="~/image/button_previous.png" OnClick="button_previous_Click" /></td>
<td style="width: 8px"></td>
<td>
<asp:ImageButton ID="button_save_next" CssClass="image_btn" runat="server" ImageUrl="~/image/button_save-next.png" OnClick="button_save_next_Click" /></td>
<td style="width: 70px"></td>
<td>
<asp:ImageButton ID="button_skip_marksas_review" CssClass="image_btn" runat="server" ImageUrl="~/image/button_skip-marks-as-review (1).png" OnClick="button_skip_marksas_review_Click" /></td>
<td style="width: 8px"></td>
<td>
<asp:ImageButton ID="button_submit" CssClass="image_btn" runat="server" ImageUrl="~/image/button_submit.png" /></td>
</tr>
</table>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="button_save_next" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="button_previous" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="button_skip_marksas_review" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
protected void button_save_next_Click(object sender, ImageClickEventArgs e)
{
string constr = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
con.Open();
j = Convert.ToInt32(ViewState["j"]) + 1;
string SelectQuestion_String = "Select * from Questions where ExamName = 'Demo'";
SqlCommand com = new SqlCommand(SelectQuestion_String, con);
SqlDataAdapter da = new SqlDataAdapter(com);
DataSet ds = new DataSet();
da.Fill(ds);
answer = ds.Tables[0].Rows[j]["Answer"].ToString();
ViewState["j"] = (int)ViewState["j"] + 1;
if (ds != null && (int)ViewState["j"] <= ds.Tables[0].Rows.Count)
{
Question_detail.Text = ds.Tables[0].Rows[j]["Question"].ToString();
Option_1.Text = ds.Tables[0].Rows[j]["Option1"].ToString();
Option_2.Text = ds.Tables[0].Rows[j]["Option2"].ToString();
Option_3.Text = ds.Tables[0].Rows[j]["Option3"].ToString();
Option_4.Text = ds.Tables[0].Rows[j]["Option4"].ToString();
answer = ds.Tables[0].Rows[j]["Answer"].ToString();
Question_No_label.Text = "Question" + " : " + ((int)ViewState["j"] + 1) + " " + "<span style='font-size:15px;font-family:Arial Rounded MT'> of " + ds.Tables[0].Rows.Count + "</span>";
}
UpdateXml();
con.Close();
}
public void UpdateXml()
{
Student_Question_paper_xml = Session["Student"].ToString() + "_" + Session["Exam"].ToString() + "_" + DateTime.Now.ToLongDateString();
DataSet Xds = new DataSet();
Response.Write(Student_Question_paper_xml);
Xds.ReadXml(Server.MapPath("~/Student_ExamPaper_xml/" + Student_Question_paper_xml + ".xml"));
question_id = (int)ViewState["j"] + 1;
DataRow Xrow = Xds.Tables[0].NewRow();
Xrow["Question_ID"] = "Question_" + question_id;
Xrow["Question_detail"] = Question_detail.Text;
Xrow["Option_1"] = Question_detail.Text;
Xrow["Option_2"] = Question_detail.Text;
Xrow["Option_3"] = Question_detail.Text;
Xrow["Option_4"] = Question_detail.Text;
Xrow["Radion_Button_index"] = Question_detail.Text;
Xds.Tables[0].Rows.Add(Xrow);
Xds.AcceptChanges();
Xds.WriteXml(Server.MapPath("~/Student_ExamPaper_xml/" + Student_Question_paper_xml + ".xml"));
}
Please Help Me.....