Go Premium for a chance to win a PS4. Enter to Win

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

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.
0
bolenka
Asked:
bolenka
  • 4
  • 4
1 Solution
 
prairiedogCommented:
1). Are you using the solution that I proposed in your related question: http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23844259.html
3). Where do you want to add this: '18/25 questions completed'?
0
 
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 story...you 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 hurry...so 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


or


25/25 Questions Completed
Compete Evaluation | Return to List


or
 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.

0
 
prairiedogCommented:
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.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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.
0
 
prairiedogCommented:
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
    Else
         hl.Visible = False
    End If
End Sub
0
 
prairiedogCommented:
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.
0
 
bolenkaAuthor Commented:
Ok, awesome. I will check it out real quick. thanks!
0
 
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.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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