VB.Net Data Repeater Help

Hello,

I have the following situation:
-A basic VB app with a single DataRepeater
-The data repeater is connected to an Access Table Via Binding Source -> Data Set

I have three fields ID, Description, PDFExists

On the data repeater, I have two txt boxes and a button.
-Txt boxes for ID and Description
-Button "View PDF"

I want to make it so that if PDFExists equals True, the button is Visible, if False, the button is Not Visible

I already have code setups the button link (essentially sets the button Tag to the unique ID number), see attached, and that works fine.  

Any suggestions on how to handle showing the button.  I suspect that if I added a text box for PDFExists, and checked it's text, I could easily accomplish this, but I would prefer to access the data directly.
Private Sub DataRepeater1_DrawItem(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs) Handles DataRepeater1.DrawItem
        btnViewPDF.Tag = e.DataRepeaterItem.Controls(NumTextBox.Name).Text
End Sub

Open in new window

compsol1993Asked:
Who is Participating?
 
käµfm³d 👽Commented:
This is kind of a hack, but you can keep the CheckBox that the boolean field defaults to (or change it to CheckBox if it's not set) and set its Visible property to false, drag a regular button onto the DataRepeater, and then in your DrawItem handler, you could add the following:
Private Sub DataRepeater1_Items(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.PowerPacks.DataRepeaterItemEventArgs) Handles DataRepeater1.DrawItem
    Dim box As CheckBox = DirectCast(e.DataRepeaterItem.Controls("PDFExistsCheckBox"), CheckBox)
    Dim btn As Button = DirectCast(e.DataRepeaterItem.Controls("Button1"), Button)

    btn.Visible = box.Checked
End Sub

Open in new window

0
 
compsol1993Author Commented:
Thanks for the advice.  I'll give this a try, and may have to go this route.

Do you (or anyone else) know of a way to accomplish this without needing an "Invisible" Check Box on the form?

Thanks
0
 
käµfm³d 👽Commented:
Do you (or anyone else) know of a way to accomplish this without needing an "Invisible" Check Box on the form?
I'm still trying to locate a way to reach the data being bound in this control. I have been unsuccessful so far, which is why I posted the hack. If I can find it, I'll post back  : )
0
 
compsol1993Author Commented:
Sounds good, the Chkbox concept does work, and it's small enough that since it's invisible, it won't be in the way.

thanks for the help
0
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.

All Courses

From novice to tech pro — start learning today.