Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

escaping pager in gridview 2

Status
Not open for further replies.

bobmmp

Programmer
Apr 22, 2002
43
US
I have a gridview that I am using in a quiz engine (VB). A have a item templete field that has 5 radio buttons. For the purpose of paging from one set of questions to the other, I have a PagerTemplete (method is previous/next). Inside the template, I have a button called submit with a command arg = next. When a user completes the page of questions and clicks the submit button, I have a sub in my code behind that is triggered on an IndexChange event which is were the result from the gridview are collected and record. My problem is when I get to the last page of questions. Once I record the last page results, I need to able to know that there are not more pages and redirect to a new aspx page or present 'thank you for taking the quiz' notice.

I have been stuck on this for a few days now and have read several tutorials on pager but none that escape the grid.

I have images of the two grids at and The first image is the first page of data and the second image is the last page which is usually the 6,7, or 8 page but it can vary between quizes.

thanks

Bob B.
 
you may want to use the Wizard web control instead of a gridview. this should have all the options you're looking for built-in.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
The reason I am not using the wizzard control is the number of steps is based on the quiz. Quizes are built dynamicly so the number of steps would change between each quiz. The page size never displays more than 8 questions at a time, but some quizes could have 5 steps and another 10?

Bob B.
 
You can use the PageIndex and PageCount properties to check if they match e.g
Code:
        If myGridView.PageIndex = myGridView.PageCount Then

        End If
However, you can also create wizard steps at runtime if needed so it may be worth spending the time to look into the method Jason suggested.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
Thanks both of you. The grid option gets me going then I can go back and revisit the wizard. Since I am not sure how many steps there will be, I had ruled the wizard option out. But now I am boing to revisit it.

Bob B.
 
i use dynamic wizard steps in my some of my projects. I create a web user control for each type of possiblity. so for a quiz you may have a web user control for
multiple choice
free response
true/false

then when the wizard is created you dynamically add a wizard step. then add the appropriate user control.

the trick[/] is getting all the responses out of each wizard step. The most OO solution would be assign a common interface to each user control. this would expose the same properties and you could collect the data.

another option woud be a switch/case statement at the end which says if control X exists do this, else do that.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Jason, Thanks again. I think one of the issues I haven't grasped yet is that the quiz question all come from a sqldb and the reason I use the gridview is that I am presenting 7 to 8 questions at a time. Please look at my screen grab and see if you still think this is the best solutions.


First thing tomorrow, I am going to do more research into the wizard control... I have used the wizard in the past but it only displays one question at a time as instead of 5 to 10 questions at a time for a total of 50-100s.

I am taking all of your advise to heart.

Bob B.
 
How about using a Repeater control then? This will allow you the flexibility to create the layout you want whilst also allowing you to implement paging.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
looking at your images the practicle option with your desired results would be the code ca8msm provided.
when the page index = the page count - 1 then display a button to save the results and show a completion message.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top