Protected Sub ContactsListView_ItemDataBound(ByVal sender As Object, _
ByVal e As ListViewItemEventArgs)
If e.Item.ItemType = ListViewItemType.DataItem Then
' Display the e-mail address in italics.
Dim EmailAddressLabel As Label = _
CType(e.Item.FindControl("EmailAddressLabel"), Label)
EmailAddressLabel.Font.Italic = True
Dim rowView As System.Data.DataRowView
rowView = CType(e.Item.DataItem, System.Data.DataRowView)
Dim currentEmailAddress As String = rowView("EmailAddress").ToString()
If currentEmailAddress = "orlando0@adventure-works.com" Then
EmailAddressLabel.Font.Bold = True
End If
End If
End Sub
As everyone has mentioned, you can loop (iterate) through each control/item within the parent control to find (findcontrol("the_control")) and get/set values.
Check out my website: http://www.TheTradeBox.com
Love collecting video games, movies and board games!
Enjoying my '11 WRX, so sexy...
exbond
Member
58 Points
144 Posts
problem in finding control?
May 11, 2012 10:20 AM|LINK
how i can find a control lost in a listview?
i have an <asp:image> in listview which bind the path form database.
how i can refer to each image individualy??? i m using my pop up function to show each selected image on popup panel using modelpopup.
i have a modalpopupextender it needs a TargetcontrolID, should i give the image1 as its target or the listview1 as targetcontrolid??
ramiramilu
All-Star
95463 Points
14106 Posts
Re: problem in finding control?
May 11, 2012 10:24 AM|LINK
Iterate Listview.Items and then you can get image controls using item[index...].FindControl("Your image");
Thanks,
JumpStart
danyal316
Member
200 Points
53 Posts
Re: problem in finding control?
May 11, 2012 11:40 AM|LINK
check this link
http://stackoverflow.com/questions/613277/find-control-in-listview-emptydatatemplate
MetalAsp.Net
All-Star
112151 Points
18246 Posts
Moderator
Re: problem in finding control?
May 11, 2012 11:52 AM|LINK
exbond
Member
58 Points
144 Posts
Re: problem in finding control?
May 11, 2012 02:05 PM|LINK
can any one give me example?how to do that?
exbond
Member
58 Points
144 Posts
Re: problem in finding control?
May 11, 2012 02:52 PM|LINK
where should i do the itrations in page load event or in listviewsselectedindex function???
i have a modalpopupextender it needs a TargetcontrolID, should i give the image1 as its target or the listview1 as targetcontrolid???
mebinici
Participant
815 Points
256 Posts
Re: problem in finding control?
May 11, 2012 04:59 PM|LINK
When you bind your control (ListView), look at these:
ListView.ItemDataBound Event
ListView.ItemCreated Event
Protected Sub ContactsListView_ItemDataBound(ByVal sender As Object, _ ByVal e As ListViewItemEventArgs) If e.Item.ItemType = ListViewItemType.DataItem Then ' Display the e-mail address in italics. Dim EmailAddressLabel As Label = _ CType(e.Item.FindControl("EmailAddressLabel"), Label) EmailAddressLabel.Font.Italic = True Dim rowView As System.Data.DataRowView rowView = CType(e.Item.DataItem, System.Data.DataRowView) Dim currentEmailAddress As String = rowView("EmailAddress").ToString() If currentEmailAddress = "orlando0@adventure-works.com" Then EmailAddressLabel.Font.Bold = True End If End If End SubAs everyone has mentioned, you can loop (iterate) through each control/item within the parent control to find (findcontrol("the_control")) and get/set values.
Love collecting video games, movies and board games!
Enjoying my '11 WRX, so sexy...