Solved

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
14
281 Views
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:)
0
Comment
Question by:bolenka
  • 8
  • 5
14 Comments
 
LVL 22

Expert Comment

by:prairiedog
Comment Utility
>>>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
 

Author Comment

by:bolenka
Comment Utility
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
 
LVL 22

Expert Comment

by:prairiedog
Comment Utility
What control do you use to display the correct answer and other stats?
0
 

Author Comment

by:bolenka
Comment Utility
I was just using a panel control with some labels in it. I make the whole panel visible after submission.
0
 

Author Comment

by:bolenka
Comment Utility
prairiedog? have I lost ya?
0
 

Author Comment

by:bolenka
Comment Utility
do you think you wil answer this or should I repost? thanks so much?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 22

Expert Comment

by:prairiedog
Comment Utility
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
 

Author Comment

by:bolenka
Comment Utility
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
 
LVL 22

Expert Comment

by:prairiedog
Comment Utility
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
 

Author Comment

by:bolenka
Comment Utility
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
 

Author Comment

by:bolenka
Comment Utility
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
 
LVL 22

Accepted Solution

by:
prairiedog earned 500 total points
Comment Utility
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
 

Author Closing Comment

by:bolenka
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now