Please help me, i tried to pass information from detailed view and to another detailed view in another page. I put this code in the first page

protected void ViewRemuneration_Click(object sender, EventArgs e)
        {
            //Button ViewRemuneration = (Button)sender;
            //string sendID = ViewRemuneration.ID;
            Response.Redirect("Remuneration.aspx?employeeId=" + DetailsView1.SelectedValue);
        }

and to the second page

protected void Page_Load(object sender, EventArgs e)
        {
            if (null == Session["UserId"])
            {
                Response.Redirect("login.aspx");
            }
            string employeeId = Request["employeeId"].ToString();
        }

but this second page won't show the id i select at the first detailed view, it only shows the first record in the database. If i pass it to gridview, it will show every record in the database.. please help me,thanks very much

You're passing the employee ID in the query string but checking a session variable? That doesn't make any sense.

First page is OK:

protected void ViewRemuneration_Click(object sender, EventArgs e)
        {
            //Button ViewRemuneration = (Button)sender;
            //string sendID = ViewRemuneration.ID;
            Response.Redirect("Remuneration.aspx?employeeId=" + DetailsView1.SelectedValue);
        }

Change the second page to:

protected void Page_Load(object sender, EventArgs e)
        {
            string employeeId = Convert.ToString(Request["employeeId"]);
            if (string.IsNullOrEmpty(employeeId))
            {
                Response.Redirect("login.aspx");
            }
            else
            {
               //Set your session variable here
            }
        }
commented: great one now i convert and it's working +1

hi thanks for the reply, i have tried but now it displays nothing.
the code in the second page looks like this

protected void Page_Load(object sender, EventArgs e)
        {
            if (null == Session["UserId"])
            {
                Response.Redirect("login.aspx");
            }
            string employeeId = Convert.ToString(Request["employeeId"]);
            string reportsSql = string.Format(
                "SELECT Performance.PerformanceID, Employee.LastName, Employee.FirstName, Performance.DateofRemark, Performance.MyPerformance, Performance.EmployeePerformance, Performance.RemarkedBy "
                 + "FROM Employee INNER JOIN Performance ON Employee.ID = Performance.ID "
                 + "WHERE Employee.ID = " + employeeId);
            AccessDataSource accessDataSource1 = new AccessDataSource();
            accessDataSource1.DataFile = "~/App_Data/Copy of elog.mdb";
            GridView1.DataSource = accessDataSource1;
            accessDataSource1.SelectCommand = reportsSql;
            GridView1.DataBind();

hey i found the mistake!
it's not just in the code behind, but i have to change the "autogenerate columns" in .aspx page to "TRUE".
thanks a lot sksnake, your post really helps, now it's working!

I'm glad you found a solution to your problem and good luck!

Please mark this thread as solved if you have found an answer to your problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.