Wrox Programmer Forums
|
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 September 5th, 2011, 04:31 AM
Registered User
 
Join Date: Sep 2011
Posts: 6
Thanks: 4
Thanked 0 Times in 0 Posts
Default Creating a query for the Review.aspx

Hi .

I just finished to read chapter 13 in this fantastic book .

I wanted to change something in my reviews.aspx page that it'll have a query, that's because i wanted that after i insert/update a new review with the DetailsView and push the insert button (or update), it'll redirect me to the reviews page of the right GenreID that just have been Insterted/update, and the situation now is that it redirect me only to the Reviews.aspx page and i have to look for my new/updated record by selecting the GenreID.
Is that possible to do ? if so, where should i tweak to make it happen ?

Thanks a lot !

Roni .
 
Old September 5th, 2011, 06:37 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Yes, it can be done. From a high level overview, this is what you need:

1. In DetailsView1_ItemInserted and DetailsView1_ItemUpdated retrieve the selected genre ID from the e argument and send it to EndEditing.

2. Modify EndEditing so it forwards the selected genre ID to the Reviews page

3. In Reviews.aspx, look at the query string (only when the page first loads, not after a postback) and set the SelectedValue on the Genre list when there is a valid genre ID. Here's the code to implement this:

1. (in AddEditReview.aspx.cs)
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);
}
2. (in AddEditReview.aspx.cs)
Code:
private void EndEditing(int genreId)
{
  Response.Redirect("Reviews.aspx?GenreId=" + genreId.ToString());
}
3. (In Reviews.aspx.cs)
Code:
protected void Page_Load(object sender, EventArgs e)
{
  if (!Page.IsPostBack)
  {
    string genreId = Request.QueryString.Get("GenreId");
    if (!string.IsNullOrEmpty(genreId))
    {
      DropDownList1.SelectedValue = genreId;
    }
  }
}
You still run the risk that the new review is not on the first page of the GridView with reviews, but at least the correct genre has been selected.

Hope this helps,

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 September 5th, 2011, 06:46 AM
Registered User
 
Join Date: Sep 2011
Posts: 6
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Thanks so much Imar ! you are amazing with the way you explain, and the attention you give to every question .
Your book is fantastic and i recommended it already to a few friends that bought it, and will keep recommend it as it great for beginners..

Thanks ! :) Roni .
 
Old September 5th, 2011, 06:50 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
Your book is fantastic and i recommended it already to a few friends that bought it, and will keep recommend it as it great for beginners..
Thank you. Much appreciated!

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a Calendar from query gfgaldb Access 1 February 8th, 2010 05:52 PM
Query in a browser/address bar i.e. default.aspx?i takwirira ASP.NET 2.0 Basics 1 June 12th, 2008 07:58 AM
Help Creating Snapshot Query eusanpe Access VBA 3 July 12th, 2007 01:33 PM
Creating new Table Row in Access with ASPX BramuS ASP.NET 1.0 and 1.1 Basics 3 May 9th, 2005 09:22 AM
Creating Reports from a Query by Form jBranch Access VBA 0 March 3rd, 2004 09:04 AM





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