Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 29th, 2013, 04:04 PM
Friend of Wrox
Points: 595, Level: 8
Points: 595, Level: 8 Points: 595, Level: 8 Points: 595, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 126
Thanks: 39
Thanked 2 Times in 2 Posts
Default Ch. 15 - Exercise 2

Hi Imar,

I was trying to add the functionality in ex. 2 to the original AddEditReview.aspx page. I tried changing the

Response.Redirect("Reviews.aspx"); in EndEditing() to

Response.Redirect(string.Format("Reviews.aspx?Genr eId={0}",GenreList.SelectedValue)); ---> But I noticed I could not directly access the genre list in the DetailsView template.

Is there a way to access the value of the selected item in the genre list?


Thanks,

Tulsi
 
Old January 29th, 2013, 04:23 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Tulsi,

You can access the ID in the Inserted and Updated events and then forward that to EndEditing:

Code:
protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
  int genreId = Convert.ToInt32(e.Values["GenreId"]);
  EndEditing(genreId);
}

protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
{
  int genreId = Convert.ToInt32(e.NewValues["GenreId"]);
  EndEditing(genreId);
}

private void EndEditing(int genreId)
{
  Response.Redirect(string.Format("Reviews.aspx?GenreId={0}", genreId));  
}
Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old January 31st, 2013, 12:30 PM
Friend of Wrox
Points: 595, Level: 8
Points: 595, Level: 8 Points: 595, Level: 8 Points: 595, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 126
Thanks: 39
Thanked 2 Times in 2 Posts
Default

Thank you. This worked perfectly!

Tulsi




Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 15 - Exercise #2 - solution(p.750) Tulsi BOOK: Beginning ASP.NET 4 : in C# and VB 3 January 25th, 2013 03:44 PM
ch 3 Exercise 1 Phrog BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 4 October 24th, 2012 12:06 PM
Exercise 1 from Ch 11 akumok BOOK: Beginning ASP.NET 4 : in C# and VB 7 July 20th, 2012 02:17 AM
Ch 15 exercise 2 don't need to call DataBind Notso BOOK: Beginning ASP.NET 4 : in C# and VB 1 April 15th, 2012 04:11 AM
My solution to exercise 6, on ch.2 - help rjm BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 July 28th, 2010 05:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.