Link to home
Start Free TrialLog in
Avatar of kimmie8000
kimmie8000Flag for United States of America

asked on

After binding my session variables at set to 0

Once the code is binds to the grid.  I lose my session variables which makes updating an issue.

Can someone tell me how to keep my session variable for the update part of the LINQ query?

public void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        LabelAcknMessage.Text = string.Empty;
        GridView1.EditIndex = e.NewEditIndex;
        // Get table and row for editing with index selected... This is when you click edit.
        string strJobTitleName = (GridView1.Rows[e.NewEditIndex].FindControl("lblJobTitle") as Label).Text;
        if (strJobTitleName != null)
        {
            HCGASF_MaintDataContext db = new HCGASF_MaintDataContext();
            var JobTitle = (from jt in db.JobTitles
                                where jt.JobTitleName == strJobTitleName
                            select jt).SingleOrDefault();
            Session["OLD_JobTitleID"] = JobTitle.JobTitleID;
            // test string make sure it is in the right number.
            string strTitle = Session["OLD_JobTitleID"].ToString();
            intTitle = Convert.ToInt32(strTitle);
        }

        string strHCApplicationName = (GridView1.Rows[e.NewEditIndex].FindControl("lblHCApplication") as Label).Text;
        if (strHCApplicationName != null)
        {
            HCGASF_MaintDataContext db = new HCGASF_MaintDataContext();
            var HCApp = (from ap in db.HomeCareSoftwareLists
                         where ap.HCApplication == strHCApplicationName
                            select ap).SingleOrDefault();
            Session["OLD_HCApplicationID"] = HCApp.HCSoftwareID;
            // test string make sure it is in the right number.
           string strHC = Session["OLD_HCApplicationID"].ToString();
           intHC = Convert.ToInt32(strHC);
        }



        BindData();
    }
ASKER CERTIFIED SOLUTION
Avatar of kimmie8000
kimmie8000
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Aaron Jabamani
UR title says session values are lost after u bind data. Is this still there ? if so can we also see binddata method code ?

Or you a new problem ?