Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 5th, 2011, 04:31 AM
Registered User
Points: 26, Level: 1
Points: 26, Level: 1 Points: 26, Level: 1 Points: 26, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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 .
Reply With Quote
  #2 (permalink)  
Old September 5th, 2011, 06:37 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
  #3 (permalink)  
Old September 5th, 2011, 06:46 AM
Registered User
Points: 26, Level: 1
Points: 26, Level: 1 Points: 26, Level: 1 Points: 26, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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 .
Reply With Quote
  #4 (permalink)  
Old September 5th, 2011, 06:50 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 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!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:23 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.