How do I prevent the updating of a record from removing my record from the current datasource dataset for paging purposes?

Posted on 2008-10-24
Medium Priority
Last Modified: 2013-11-07
Ok, prairiedog was nice enough to help me with my last question...but, now i have a related question to the same problem.

I have a Content Page that contains a formview. I have a quiz application that updates the status of the record to COMPLETED when the user answers the quiz question. I want to show the correct answer on a resutls page for the quiz and some teaching points AFTER the user chooses an ANSWER which is  AFTER the UPDATE button has been clicked (this is how my client wants it to work). However, when I update the record and change the status to COMPLETE in the database, it looks like the record is being taken out of the original query because in my original query I am asking the database to show only records that have NOT YET BEEN COMPLETED.

1) I need the records to page...ONLY AFTER the user has updated a record to COMPLETE in the database can the "Next Question" pager item be displayed...meaning, I only want the user to be able to page to the next record once they have answered the question and seen the results of the current question.

2)I am working in a formview with an item template and and edit template. The edit template calls a stored procedure to do the update(templates are in a Formview, Formview is in a ContentPage of a MasterPage.

3) Right now, I am currently trying to change the mode after UPDATE to only show the READONLY template version of the result s PAGE, but since the record gets removed from the datasource, it actually sets the readonly mode of the NEXT question(since it is actually paging to what is now the first record in the datasource dataset...so instead of showing my results on the results page of the question I want, it is showing the answer to the next question instead.

So to sum up, how do I keep the record in the dataset, so that I can change the mode from EDIT to READONLY, allowpageing only on a results page of the current record I am working on without removing the record from the dataset, or screwing up my page count?

Thanks so much.

I hope this make sense. I really am desparate. Please help
I have been working on this issue for days!!!
P.S. I am coding in VB.net so if at all possible, please post answers in vb.net:)
Question by:bolenka
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 5
LVL 22

Expert Comment

ID: 22797914
>>>want to show the correct answer on a resutls page for the quiz and some teaching points AFTER the user chooses an ANSWER which is  AFTER the UPDATE button has been clicked.
Have you got this part worked out as far as how to get the data from DB?
Do you want to display the correct answer no matter if the user's answer is correct or not?
After review the results, does the user have to click a button or something to go to the next question?

Author Comment

ID: 22798405
Hi prairiedog:) Again:) To answer your question:
1) I am already using a sqldatasource to get the data. It is a select statement the gets the select * from... where CollectionID=@CollectionID and Completed = 0. For the update statement within the sqldatasource, I am using a stored procedure (mainly because I have to update some data in some other tables at the same time) to set the Completed Column for that record to Completed= 1. Radiobuttons, not a RadIobuttonList, are bound to answer options in the content page manually (there are 15 different choices the user could make for each question i.e. 15 columns) belonging to that question/record ID. Each record/question to answer in the db has all the available columns that are needed to get the data and to make the update. In otherwords, questions come from the same record as the Answers.
The user clicks a radio button to choose an answer and then clicks the update button..."Submit Answer" at the bottom of the form to submit the answer they have just clicked. At this point I need the user to see the results WITH PAGING.
Do I need something else? included in the sqldatasource?

2) Yes, I HAVE to display the correct answer no matter if the user's answer is correct or not. I have to display the correct answer in green text with a little checkbox image if the answer is correct, and I have to display a little "X" image if the answer is wrong. I also have to provide some percentages/statistics next to the radio button answer:

"88% of people chose this answer"
"12% of people chose this answer"

I have to display this data next to each answer item..whether correct or incorrect.(this data will be calclulated from the same table based on all user answers in the table (havent finished that part yet)
Teaching Points and other information about the answer will appear on the results page with the correct answer and corresponding images.

3) After viewing the results, the user has to click on a link that says "Next Case" (meaning next question), to move onto the next record. Once the next record has been clicked, the user has to see the next question in edit mode, and then the results for that question in Readonly mode (this is just the way I have it coded with the templates now)

4)Once all the questions in the query have been set to complete, the user is done with the collection of questions/cases and I have to insert a CollectionCompletedDate Date value into the the collectionCompleteddate column of the same record/question.

Does that help?

Do I have to use a sql datasource? or object datasource. I have no objections to getting the data another way. I started this not really knowing the best way to get the data. I am using table adapters for other purposes in other parts of the application. What is the best way to get the data onto the form?
I am open to suggestions.

Let me know if you have any more questions. You are saving my life!!!! Really...thank you.

LVL 22

Expert Comment

ID: 22798887
What control do you use to display the correct answer and other stats?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 22799146
I was just using a panel control with some labels in it. I make the whole panel visible after submission.

Author Comment

ID: 22802881
prairiedog? have I lost ya?

Author Comment

ID: 22803571
do you think you wil answer this or should I repost? thanks so much?
LVL 22

Expert Comment

ID: 22803623
Hi bolenka,

I don't get on-line on Saturdays as much as I do during week days.  Besides, your question is kinda tricky and I need some time to think about it before I can give you a solid answer. I don't think you need to repost. If you can't wait until Monday, you can click "Request Attention" button located at the right lower corner of your original question post, so some advanced experts will be notified of this question and they should be able to help you. I am sorry that I didn't reply to you early.


Author Comment

ID: 22803815
no problem...I would love for you to help me...can you take a look on monday to see if it has been answered? thank you so much. I will click request attention just to see if someone else answers and then follow up on monday? I appreciate it.
LVL 22

Expert Comment

ID: 22822207
Hi bolenka,
I am sorry I didn't come here yesterday because my son was sick.
Anyway, I have come up with a solution but it is a little bit different from your requirements. I don't think you can keep the updated record after the "UPDATE" button is clicked and you know the reason.
Based on your current situation (you are using a Panel to display the original question and user's answer and other stats), I have come up with a solution. Here is how it works:
By default, the Panle is invisible, and when the "UPDATE" button is clicked, the record will be updated, the Panel will be visible with the original question and user's answer and other stats. In the Panel, there is a button called "Next Question". With some CSS tricks, we can make the Panel on top of the FormView layer, and the Panel will have a black background so user will not be able to see the next question until they hit "Next Question". Once the button is clicked, the Panel become invisible again, and the user is able to see the next question in READONLY mode.
Please refer to the attached screen shots and let me know if it is an acceptable solution. If yes, I will post the code and the CSS (I used the AdventureWorks2000 DB for my example).


Author Comment

ID: 22822569
holy moly..what a great idea!..thanks so much prarie dog...let me get my brain wrapped around it and I'll get back to you.  I had not even thought of a solution like this. Very creative. I truly appreciate it. Thanks for responding. I certainly understand having sick children. been there:) I will analyze and get back to you.

Author Comment

ID: 22832806
Hi prairie dog...I have thought about your suggestion, and I would really like to try it Any code you could send me including the .css would be fantastic...then I can assign points:)
LVL 22

Accepted Solution

prairiedog earned 2000 total points
ID: 22832952
See attached Panel definition and the CSS styles for the Panel and the <div> tag inside of the Panel. Let  me know if you have trouble understanding any of the code.
'Panel definition, make changes accordingly. It is the CssClass that does the trick.
<asp:Panel ID="pnlResults" runat="server" Width="100%" Visible="false" CssClass="PopupBackground">
<div class="Popup">
	The original question and user's answer go here.<br />
	<br />
	Some other stats go here.<br />
	<br />
	<br />
<asp:Button ID="btnNextQuestion" runat="server" Text="Next Question->" /><br />
'CSS styles for the Panel and the <div> tag
	position: fixed;
	top: 0;
	left: 0;
	height: 100%;
	width: 100%;
	min-height: 100%; 
	min-width: 100% 
	background-color: #ffff99;
	color: black;
	width: 50%;
	text-align: center;
	vertical-align: middle;
	position: fixed;
	bottom: 50%;
	left: 25%;
'After updated the record, add the following three lines:
Me.pnlResults.Visible = True
Me.FormView1.DefaultMode = FormViewMode.ReadOnly
Me.FormView1.AllowPaging = True
'The Next Question Button's click event: hide the Panel
Protected Sub btnNextQuestion_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNextQuestion.Click
	Me.pnlResults.Visible = False
End Sub

Open in new window


Author Closing Comment

ID: 31509627
thanks prairiedog...I'll take it. I hope you answer more of my questions in the future. You have been really helpful!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question