Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

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

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:)
0
bolenka
Asked:
bolenka
  • 8
  • 5
1 Solution
 
prairiedogCommented:
>>>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?
0
 
bolenkaAuthor Commented:
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.

0
 
prairiedogCommented:
What control do you use to display the correct answer and other stats?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
bolenkaAuthor Commented:
I was just using a panel control with some labels in it. I make the whole panel visible after submission.
0
 
bolenkaAuthor Commented:
prairiedog? have I lost ya?
0
 
bolenkaAuthor Commented:
do you think you wil answer this or should I repost? thanks so much?
0
 
prairiedogCommented:
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.

Jeffrey
0
 
bolenkaAuthor Commented:
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.
0
 
prairiedogCommented:
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).

2008-10-28-092604.jpg
2008-10-28-092858.jpg
2008-10-28-092944.jpg
0
 
bolenkaAuthor Commented:
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.
0
 
bolenkaAuthor Commented:
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:)
0
 
prairiedogCommented:
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 />
</div></asp:Panel>
 
'CSS styles for the Panel and the <div> tag
.PopupBackground 
{
	position: fixed;
	top: 0;
	left: 0;
	
	background-color:#000000;
		
	height: 100%;
	width: 100%;
	
	min-height: 100%; 
	min-width: 100% 
	
}
 
.Popup
{
	background-color: #ffff99;
	color: black;
	width: 50%;
	text-align: center;
	vertical-align: middle;
	position: fixed;
	bottom: 50%;
	left: 25%;
	font-weight:bold;
}
 
'FormView1_ItemUpdated
'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

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

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now