pass id wont work

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jun 2009
Posts: 14
Reputation: missbeginner is an unknown quantity at this point 
Solved Threads: 0
missbeginner missbeginner is offline Offline
Newbie Poster

pass id wont work

 
0
  #1
Jul 6th, 2009
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

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

and to the second page
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3. if (null == Session["UserId"])
  4. {
  5. Response.Redirect("login.aspx");
  6. }
  7. string employeeId = Request["employeeId"].ToString();
  8. }

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
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 14
Reputation: missbeginner is an unknown quantity at this point 
Solved Threads: 0
missbeginner missbeginner is offline Offline
Newbie Poster

Re: pass id wont work

 
0
  #2
Jul 6th, 2009
oh and one more, in the website it displays like this :
http://localhost:1193/ViewReports.aspx?employeeId=4

so it has read which Id i select, but won't show the particular detail i need. thanks again
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,215
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 572
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: pass id wont work

 
1
  #3
Jul 6th, 2009
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:
  1. protected void ViewRemuneration_Click(object sender, EventArgs e)
  2. {
  3. //Button ViewRemuneration = (Button)sender;
  4. //string sendID = ViewRemuneration.ID;
  5. Response.Redirect("Remuneration.aspx?employeeId=" + DetailsView1.SelectedValue);
  6. }

Change the second page to:
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3. string employeeId = Convert.ToString(Request["employeeId"]);
  4. if (string.IsNullOrEmpty(employeeId))
  5. {
  6. Response.Redirect("login.aspx");
  7. }
  8. else
  9. {
  10. //Set your session variable here
  11. }
  12. }
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 14
Reputation: missbeginner is an unknown quantity at this point 
Solved Threads: 0
missbeginner missbeginner is offline Offline
Newbie Poster

Re: pass id wont work

 
0
  #4
Jul 7th, 2009
hi thanks for the reply, i have tried but now it displays nothing.
the code in the second page looks like this

  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3. if (null == Session["UserId"])
  4. {
  5. Response.Redirect("login.aspx");
  6. }
  7. string employeeId = Convert.ToString(Request["employeeId"]);
  8. string reportsSql = string.Format(
  9. "SELECT Performance.PerformanceID, Employee.LastName, Employee.FirstName, Performance.DateofRemark, Performance.MyPerformance, Performance.EmployeePerformance, Performance.RemarkedBy "
  10. + "FROM Employee INNER JOIN Performance ON Employee.ID = Performance.ID "
  11. + "WHERE Employee.ID = " + employeeId);
  12. AccessDataSource accessDataSource1 = new AccessDataSource();
  13. accessDataSource1.DataFile = "~/App_Data/Copy of elog.mdb";
  14. GridView1.DataSource = accessDataSource1;
  15. accessDataSource1.SelectCommand = reportsSql;
  16. GridView1.DataBind();
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 14
Reputation: missbeginner is an unknown quantity at this point 
Solved Threads: 0
missbeginner missbeginner is offline Offline
Newbie Poster

Re: pass id wont work

 
0
  #5
Jul 7th, 2009
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!
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,215
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 572
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: pass id wont work

 
0
  #6
Jul 7th, 2009
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.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the ASP.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC