when i click on the treeview the page gets refresh and the control wont go to roottree_SelectedNodeChanged
Plz anyone help me......
/* Document */
private void GenerateMarksTree(StudentManagement.Student stud)
{
TreeView roottree = new TreeView();
roottree.ForeColor = Color.Black;
roottree.ShowLines = true;
TreeNode root = new TreeNode();
root.Text = stud.Branch.ToString();
root.Value = "";
roottree.ShowLines = true;
roottree.ForeColor = Color.Black;
roottree.Font.Bold = true;
roottree.Font.Size = 10;
roottree.Nodes.Add(root);
StudentManagement.StudentManagementSoap Service2 = new StudentManagement.StudentManagementSoapClient();
GetClassDetailsRequest request2 = new GetClassDetailsRequest();
request2.Body = new GetClassDetailsRequestBody();
request2.Body.id = stud.StudentId;
GetClassDetailsResponse response2 = Service2.GetClassDetails(request2);
foreach (StudentClassDetails studentdetails in response2.Body.GetClassDetailsResult)
{
TreeNode childNode = new TreeNode();
childNode.Value = "";
childNode.Text = "Semester: " + studentdetails.ClassId.ToString(); //sem.SemistarId.ToString();
root.ChildNodes.Add(childNode);
StudentManagement.StudentManagementSoap studentService = new StudentManagement.StudentManagementSoapClient();
GetExamListRequest studentrequest = new GetExamListRequest();
studentrequest.Body = new GetExamListRequestBody();
studentrequest.Body.studentdetails = studentdetails;
GetExamListResponse studentresponse = studentService.GetExamList(studentrequest);
foreach (Examination examList in studentresponse.Body.GetExamListResult)
{
TreeNode childNode1 = new TreeNode();
//childNode1.SelectAction = new EventHandler(roottree_SelectedNodeChanged);
childNode1.Value = examList.Exam_Id.ToString();
childNode1.Text = examList.Exam_Name + "" + examList.Start_Date.ToShortDateString();
childNode.ChildNodes.Add(childNode1);
}
childNode.Expanded = false;
}
Panelleft1.Controls.Clear();
Panelleft1.Controls.Add(roottree);
//roottree.SelectedValue += new EventHandler(roottree_SelectedNodeChanged);
roottree.SelectedNodeChanged += new EventHandler(roottree_SelectedNodeChanged);
//roottree.SelectedNodeChanged += new EventHandler(roottree_SelectedNodeChanged);
}
protected void roottree_SelectedNodeChanged(object sender, EventArgs e)
{
TreeView treeView = (TreeView)sender;
if (treeView.SelectedValue != null && treeView.SelectedValue != "")
{
if (Session["User"] != null)
{
User user = (User)Session["User"];
StudentManagementSoap service = new StudentManagementSoapClient();
GetMarksListByIdRequest request = new GetMarksListByIdRequest();
request.Body = new GetMarksListByIdRequestBody();
request.Body.examId = treeView.SelectedValue;
request.Body.id = user.TypeOfUserId;
GetMarksListByIdResponse response = service.GetMarksListById(request);
DataSet ds = new DataSet("DS");
DataTable dt = ds.Tables.Add("Result");
dt.Columns.Add("Subject Name", typeof(string));
dt.Columns.Add("Maximum Marks", typeof(int));
dt.Columns.Add("Marks Obtained", typeof(int));
dt.Columns.Add("Result", typeof(string));
foreach (Marks mk in response.Body.GetMarksListByIdResult)
{
DataRow dr = dt.NewRow();
dr["Subject Name"] = mk.SubjectName.ToString();
dr["Maximum Marks"] = int.Parse(mk.MaximumMarks.ToString());
dr["Marks Obtained"] = int.Parse(mk.MarksObtained.ToString());
dr["Result"] = mk.Result.ToString();
dt.Rows.Add(dr);
}
GridviewMarks.Font.Bold = true;
GridviewMarks.Font.Size = 12;
GridviewMarks.Attributes.Add("Align", "left");
GridviewMarks.DataSource = ds;
GridviewMarks.DataBind();
}
}
}