How do I conditionally add dynamic hyperlinks to the Formview pager template using ASP.NET vb?

I am using a Formview with Paging Enabled. My client wants to show some Hyperlinks based on some specific circumstances. Each page represents a quiz question. Here are the requirements for creating the links conditionally (please keep in mind that my Formview is in a Content Page:

1)Once all 25 quizes have been completed (completed meaning the individual record for each quiz question is set to Completed = 'true'), the client wants a hyperlink that takes you to a page to "Complete Evaluation". This Evaluation Link can only be shown if the user has not  yet entered an evaluation record into the evaluation table.
2) The evaluation Link can only be shown once the person completes the last quiz question( I guess this would be on postback after completing the last record.
3)I have to show a count of Completed questions like '18/25 questions completed'

In what event do I create these hyperlinks?
How do I add them to the PagerTemplate dynamically?

Any info you could give would be greatly appreciated.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

1). Are you using the solution that I proposed in your related question:
3). Where do you want to add this: '18/25 questions completed'?
bolenkaAuthor Commented:
actually, I am not sure if I will have time to implement your solution overall with out a lot of css changes (since I already have a certain css implemented with master pages), so I will try to go back to institute that after I have a chance to really analyze how it looks, but either way, I still need to get the paging to work. I actually explained the problem that you and I had discussed to the client yesterday, and he wants to try to implement it the way it is for right now, which means, I am just going to work around the recordset problem for now(he mentioned something about using the page_unload to update the record to complete which still would remove the record from the recordset, but hopefully, I will still be able to see all of the data before it is removed). Anyway, I havent had time to look into it, but my client did research and found that maybe we could use the page_unload to set the completed = true ...anyway, that is another know they just want a quick fix, so I am temporarily going to get rid of the readonly and edit modes, and just use edit mode. this doesnt solve my problem of taking the record out of the recordset...anyway regardless of the solution I use, I still have to get the pager links in the templates correct....for now, I will have to come back to implement the css issue because they just don't want to do it right now...but that doesnt mean your hard work was for nothing!!! I learned a great deal from your explanation, and i plan to come back to it. I am rambling due to being in a sorry:)

To answer your other question:
For now, I think I just want the 18/25 completed records to show up right above the others like this:

18/30 Questions Completed
Go To Next Question | Return to LIst


25/25 Questions Completed
Compete Evaluation | Return to List

 if Evaluation has previously been completed

25/25 Question Completed
Print Certificate | Return to List

I think the footer (pagertemplate) would be centered? Don't you think? What do you think? THank you so much.

Hi bolenka,
The reason I asked you if you are using my solution is because if you are, then you need to go a different route to implement the new requirements (you may need to get all the reuirements altogether; the requirement change in the coding phase is a real pain).
Anyway, your client misunderstood Page_Unload event. This event fires right before the page is rendered into the client browser. Do a search on "ASP.NET Page Life Cycle" and you will understand more.
If you want to do batch update, then you will probablly need to handle the update process manually, instead of using SqlDataSource's update process.
Seems to me, there are still some unknowns and it is hard for me to give you a solid suggestion based on my knowledge. Maybe other experts have a different opion.
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

bolenkaAuthor Commented:
I understand what you mean prairiedog. This project has been really frustrating and they have been chaning the requirements a lot, but I kind of don't have a choice. I did everything I could to avoid it, but it just seems to not be my day if you will.

How about this? I can make my question easier to understand since I was blabbering on before and probably confused you:)

What is the syntax for dynamically creating conditional Navigation links in the pager template for formview?
 In other words, If I want to add some links to the pager template on postback, how would I do that? I guess that would be my question for now. I just want to dynamically add some links to the pager template (as shown above). Dont worry about the paging. What event do I use to create these links conditionally? And what would the syntax be? Does that make sense? Sorry for the confusion. Thanks again.
Generally speaking, here is how you create a HyperLink control in FormView's Pager (I assume the pager is at the bottom) and retrieve it later on:
1. Create a HyperLink control in FormView's PagerTemplate field.
2. In code behind, you will need to use FormView's DataBound event handler:

Private Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.DataBound
       Dim pagerRow As FormViewRow = Me.FormView1.BottomPagerRow
        Dim hl As HyperLink = CType(pagerRow.Cells(0).FindControl("HyperLink1"), HyperLink)
      'here you check if the user finished all questions, then display the hyperlink,
     ' otherwise, hide the hyperlink
     If (conditionIsTrue) Then
          hl.Visible = True
         hl.Visible = False
    End If
End Sub
So to sum up, you do not dynamically create the links. You create it in PaterTemplate, then toggle it on or off in code-behind based on the condition.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bolenkaAuthor Commented:
Ok, awesome. I will check it out real quick. thanks!
bolenkaAuthor Commented:
sorry prarie dog...busy week/weekend...deadlines, kids, tricks or treats and election...anyway...sorry it took so long. You have helped me greatly. getting ready to post another in fact:) thanks again.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.