Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Find Control iniside Listview

Posted on 2011-02-25
6
Medium Priority
?
322 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 400 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 1600 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

722 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