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 | 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
  #11 (permalink)  
Old November 25th, 2011, 03:08 PM
Authorized User
Points: 313, Level: 6
Points: 313, Level: 6 Points: 313, Level: 6 Points: 313, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
Default GridView

First of all thanks for your prompt reply! Great to have access to such expert help!

Sorry for being rather vague in the last entry above. I will now be more specific.

As wrote above, I'm on my second trip through the book and thoroughly enjoying the trip even more this time as I missed a few details the first time. Just starting Chapter 8 again User Controls and since this is my second pass, it will go faster. Planet Wrox is running and looking perfect this time through.

Based on just your book and your previous excellent help, I've successfully written code for a simple multiple choice online exam with 16 multiple choice questions. All 16 questions are in one (Form) page, so the user has to scroll down as he progresses. At this stage, I favour simplicity at my end rather at the end user. Since my online exam is one Form, I need to insert 16 radio button, multiple choice (A thru D) selections and potential comments into my database table. Below each question is a text area where the user can input comments. There is a single Submit button at the bottom of the exam page.

Validation makes sure all questions are answered when the submit button is clicked. IF validation fails the user is reminded to answer the specific question he/she missed. IF validation passes, the user is sent to another page, where he/she sees each question, the answers they selected and any comments entered.

Once I get this exam running locally it will be "ported" to my institutions intranet where it will be connected to an institutional SQL database. There is a structured and controlled, development/integration/production environment as there was for ColdFusion development.

So while the end user side of this exam is written, making the next jump to database connectivity (more like database validation) is proving difficult.

I'm not able to verify, data is being inserted into my database table. While GridView "sees" my table, it reports just "abcd" under each column instead of what was entered. I have the proper database connections string setup, but I'm sure C# 'insert data" code is missing from the code behind file associated with my form.

So here are my specific questions:

Is GridView meant to be mostly an "on page" tool to validate for the developer CRUD (insert, update and delete) database connectivity is working?

IF GridView validates my database connectivity, it's obvious I need to write C# code in the Form's code behind file, specific for the button click event handler to insert into the database table, correct?

What section in the book would be the most helpful with regard to writing this code?

I'm close to getting things to "CLICK" with that Submit button.
When it happens it's going to be sweet!!

There are probably simpler ways to do this, however I need to sort things out THIS way, as it's basically the ColdFusion way, which I'm more familiar with.

Thanks again!

JJ
Reply With Quote
  #12 (permalink)  
Old November 25th, 2011, 03:47 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I am still not sure I entirely understand the problem as I miss the link between yorur questionnaire and the GridView. Not seeing any code or more detailed description makes this hard to understand.

Quote:
Is GridView meant to be mostly an "on page" tool to validate for the developer CRUD (insert, update and delete) database connectivity is working?
Again: not at all. I use the GridView control in many situations in real-world applications.

To me it seems you seem to be using the wrong tool for the job. A GridView is designed for the following four core tasks:

1. Display tabular data in rows and columns (e.g. much like a spreadhsett)
2. Provide ways to sort and page the displayed data
3. Edit that data
4. Delete data

Inserting is *not* a feature of the GridView. There are work arounds, but they are typicaly messy.

So, what I would do is the one following:

1. Determine if the GridView is indeed the wrong tool. If I better understand what it is you need to do, I may help you with that
2. If it's not, switch to a different control. I would recommend looking at theListView control. As an alternative, you could look into using hand coded pages in markup and then use EF to insert / update in the database.

I think you may be stuck a bit in your CF thinking. You need to look and think outside the box to better understand and see the alternatives.

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!

Last edited by Imar; November 25th, 2011 at 04:26 PM.. Reason: Changed VF to CF
Reply With Quote
  #13 (permalink)  
Old November 25th, 2011, 04:11 PM
Authorized User
Points: 313, Level: 6
Points: 313, Level: 6 Points: 313, Level: 6 Points: 313, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
Default Regarding GridView

OK thanks!

What do you mean by EF (Entity Framework?) and VF?

I feel Chapter 14 LINQ and the ADO.NET Entity Framework, has what I need. ListView is there and a Try It may help me. I will keep working through the book though and not jump ahead to Chapter 14. I didn't actually get that far in the book the first time.

I realize you need to see code to help the most, so will work through the next 5 chapters and get back to you when get to chapter 14.

I'm just trying to insert data into my database table from a form when the submit button is clicked. Not much else.

ColdFusion uses a separate "action" page with a SQL insert statement. I'd use another page with a SQL query to check and see if the data got previously inserted. I just want to do the same with ASP.NET at this point.

Cheers!
Jim J

Last edited by jpjamie; November 25th, 2011 at 04:14 PM..
Reply With Quote
  #14 (permalink)  
Old November 25th, 2011, 04:29 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
What do you mean by EF (Entity Framework?) and VF?
Sorry, meant CF - Cold Fusion. And yes, EF is Entity Framework

Quote:
I feel Chapter 14 LINQ and the ADO.NET Entity Framework, has what I need. ListView is there and a Try It may help me.
Yes, correct.

Quote:
ColdFusion uses a separate "action" page with a SQL insert statement. I'd use another page with a SQL query to check and see if the data got previously inserted. I just want to do the same with ASP.NET at this point.
You can do that with the "hand coding" scenario. In .NET 4.5 this will be even easier when you get data binding capabilities. But that'll take some time.... ;-)

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!
Reply With Quote
  #15 (permalink)  
Old November 25th, 2011, 04:38 PM
Authorized User
Points: 313, Level: 6
Points: 313, Level: 6 Points: 313, Level: 6 Points: 313, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
Default Chapter 14

OK thanks!

I just read the third paragraph in Chapter 14's Summary and it looks like this will be the chapter where I "finger" things out!

Looking forward to .NET 4.5, but will clean my plate with 4.0 before moving onto the next plate! Do you plan on updating this book for .NET 4.5?

Nothing like having your "foot in the door" with that one!


Jim

Last edited by jpjamie; November 25th, 2011 at 04:43 PM.. Reason: Additional content
Reply With Quote
  #16 (permalink)  
Old November 26th, 2011, 07:38 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
Do you plan on updating this book for .NET 4.5?
Yes, I do. Already working on some plans for that....

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
Ajax Extender Controls not working dotnetDeveloper ASP.NET 4 General Discussion 1 May 27th, 2010 04:33 PM
Chapter 1 Page 24 Data Grid + Linked List Box not working VS2008 nineismine BOOK: Beginning ASP.NET 2.0 and Databases 0 May 10th, 2009 03:11 PM
Problem with Try it Out List Controls phage BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 6 September 15th, 2008 02:15 PM
working with 2 user controls hossrad C# 9 May 13th, 2008 09:21 AM
ASP List Controls rsearing ASP.NET 2.0 Basics 0 September 25th, 2006 09:44 PM



All times are GMT -4. The time now is 07:29 AM.


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