 |
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
|
|
|
|
|

November 25th, 2011, 03:08 PM
|
|
Authorized User
|
|
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
|
|
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
|
|

November 25th, 2011, 03:47 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
Last edited by Imar; November 25th, 2011 at 04:26 PM..
Reason: Changed VF to CF
|
|

November 25th, 2011, 04:11 PM
|
|
Authorized User
|
|
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
|
|
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..
|
|

November 25th, 2011, 04:29 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

November 25th, 2011, 04:38 PM
|
|
Authorized User
|
|
Join Date: Mar 2011
Posts: 74
Thanks: 21
Thanked 2 Times in 2 Posts
|
|
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
|
|

November 26th, 2011, 07:38 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Quote:
|
Do you plan on updating this book for .NET 4.5?
|
Yes, I do. Already working on some plans for that....
Imar
|
|
 |
|