Solved

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

Posted on 2008-10-29
8
721 Views
Last Modified: 2012-06-27
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
Comment
Question by:bolenka
  • 4
  • 4
8 Comments
 
LVL 22

Expert Comment

by:prairiedog
ID: 22842326
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
 

Author Comment

by:bolenka
ID: 22843359
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
 
LVL 22

Expert Comment

by:prairiedog
ID: 22845135
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
 

Author Comment

by:bolenka
ID: 22849077
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 22

Expert Comment

by:prairiedog
ID: 22849962
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
 
LVL 22

Accepted Solution

by:
prairiedog earned 500 total points
ID: 22849985
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
 

Author Comment

by:bolenka
ID: 22850466
Ok, awesome. I will check it out real quick. thanks!
0
 

Author Closing Comment

by:bolenka
ID: 31511534
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

747 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