Solved

Find Control iniside Listview

Posted on 2011-02-25
6
320 Views
Last Modified: 2012-05-11
I am trying to access a printbutton inside my listview control on a 3.5 asp form.

What I am trying to accomplish is to call a java script which validates the checkboxes on the lsitview.

Where should I been creating this sub procedure?

How do i access the print button?


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here

Dim myButtonPrintOut1 As Button = CType(ListView1.FindControl("printButton1"), Button)
 myButtonPrintOut1.Attributes.Add("onclick", "return checkboxChecked()")

 End Sub

Open in new window

0
Comment
Question by:TonyReba
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 9

Assisted Solution

by:rawinnlnx9
rawinnlnx9 earned 100 total points
ID: 34984415
0
 
LVL 9

Author Comment

by:TonyReba
ID: 34984459
well not really I am trying to fire an event on mybuttonprint click which will call a javascript , but my code doesnt seem to find it
0
 
LVL 4

Expert Comment

by:Tuyau2poil
ID: 34986286
you must add  onitemdatabound="ListView1_ItemDataBound" to listview1 control in aspx section and put that code in your vb section :

Protected Sub ListView1_ItemDataBound(sender As Object, e As ListViewItemEventArgs)
      If e.Item.ItemType = ListViewItemType.DataItem Then
            Dim myButtonPrintOut1 As Button = CType(e.item.FindControl("printButton1"), Button)            
            myButtonPrintOut1.Attributes.Add("onclick", "return checkboxChecked()")
      end if
End Sub
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Author Comment

by:TonyReba
ID: 34997252
Hi thanks for your advise , unfortunately when I press print the javascript is not being called,,,?
Protected Sub ListView1_ItemDataBound(ByVal sender As Object, ByVal e As ListViewItemEventArgs)
        If e.Item.ItemType = ListViewItemType.DataItem Then
            Dim myButtonPrintOut1 As Button = CType(e.item.FindControl("printButton1"), Button)
            myButtonPrintOut1.Attributes.Add("onClientClick", "checkboxChecked()")
            myButtonPrintOut1.OnClientClick = "javascript:return confirm('You wish to do this?');"

        End If
    End Sub

Open in new window

0
 
LVL 4

Accepted Solution

by:
Tuyau2poil earned 400 total points
ID: 34998518
can you verifie aspx listview control is similar to this in aspx code ?:

<asp:ListView ID="ListView1" runat="server"
            OnItemDataBound="ListView1_ItemDataBound" DataKeyNames="something"
            DataSourceID="SqldatasourceXXX" >
            <ItemTemplate>              
               <tr style="background-color: #FFFBD6;color: #333333;">
                    <td>
                        <asp:Label ID="myID1" runat="server" Text='<%# Eval("something") %>' />
                    </td>
                    <td>
                        <asp:Label ID="myID2" runat="server" Text='<%# Eval("something_else") %>' />
                    </td>
                     <td>
                        <asp:button ID="printbutton1" runat="server" Text='PRINT' />                    </td>
                </tr>
            </ItemTemplate>
           
ensure that "ListView1_ItemDataBound" is fired by debugging and putting break-points in codebehind.
Alan

0
 
LVL 9

Author Closing Comment

by:TonyReba
ID: 35000371
got it, thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

631 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