karthik v

karthik v

  • NA
  • 109
  • 69.5k

AutoSave the aspx page data

May 4 2011 6:38 PM
Hi Experts
               I am having a problem with saving the page data into a sql database.Initially the requirement is to save the page form data into a sql database in an xml format.On button Click event  i am saving the data into the database.Here i have a tree view which is dynamically populated .So when the user navigated from one page to other page user has to click the save button and then navigate to other page.so now we need the page data to be saved automatically to the database when the user navigates from page to page in the tree view.Here is little code on the button click event .i tried to write the same in the page unload event but did not work out.Can anyone help me out.
protected void btnSaveOcp_Click(object sender, EventArgs e)
    {
        int PropId = Convert.ToInt32(Request.QueryString["PropId"]);
        int CategoryId = Convert.ToInt32(Request.QueryString["CategoryId"]);
        int SubCategoryId = Convert.ToInt32(Request.QueryString["SubCategoryId"]);
        List<LobTableVO> lobTableVOs = (List<LobTableVO>)Session["LabTableVos"];
        LobTableVO lobTableVO = lobTableVOs.Where(lt => lt.PropId == PropId && lt.CategoryId == CategoryId && lt.SubCategoryId == SubCategoryId).SingleOrDefault();
        xelement = xdoc.CreateElement("UMB");
        xdoc.AppendChild(xelement);
        IsSet = false;
        GetControlList(Master.FindControl("ContentPlaceHolder1").Controls);
        lobTableVO.LobXmlData = xdoc.OuterXml;
        lobTableDao.Save(lobTableVO);
    }

Answers (4)