6 4582
if you want to use it from an event of that repeater such as ItemDataBound
you can use :
If e.Item.ItemType = ListItemType.He ader Then
CType(e.Item.Co ntrols(0).FindC ontrol("Label1" ), Label).Text = "Something"
End If
if you want to access it from other method you can use:
Repeater1.Contr ols(0).FindCont rol("Label1")
Regards
Martin
"Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message
news:ca******** @kcweb01.netnew s.att.com... On my code behind page, how can I reference a Label control that's
included in a Repeater?
In other words, given:
<asp:Repeater id="Repeater1" runat="server"> <HeaderTemplate > <table> <tr> <td><asp:Labe l ID="Label1" runat="server"> </asp:Label></td>
How can I reference Label1.Text in my VB code? (note that Label1 does not get repeated as it's in the header)
-- Tom Kaminski IIS MVP http://www.iistoolshed.com/ - tools, scripts, and utilities for running
IIS http://mvp.support.microsoft.com/ http://www.microsoft.com/windowsserv...y/centers/iis/
Hi Tom,
After you bind the repeater, you should be able to get it with
lblCntrl = Repeater1.Contr ols(0).FindCont rol("Label1")
Sample code below.
Ken
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles MyBase.Load
Dim lblCntrl As Label
Repeater1.DataS ource = CreateDataSourc e()
Repeater1.DataM ember = "StringValu e"
Repeater1.DataB ind()
lblCntrl = Repeater1.Contr ols(0).FindCont rol("Label1")
lblCntrl.Text = "The new text"
End Sub
Function CreateDataSourc e() As DataTable
Dim dt As New DataTable
Dim dr As DataRow
dt.Columns.Add( New DataColumn _
("IntegerValue" , GetType(Int32)) )
dt.Columns.Add( New DataColumn _
("StringValu e", GetType(String) ))
dt.Columns.Add( New DataColumn _
("CurrencyValue ", GetType(Double) ))
dt.Columns.Add( New DataColumn _
("Boolean", GetType(Boolean )))
Dim i As Integer
For i = 0 To 8
dr = dt.NewRow()
dr(0) = i
dr(1) = "Item " + i.ToString()
dr(2) = 1.23 * (i + 1)
dr(3) = (i = 4)
dt.Rows.Add(dr)
Next i
Return dt
End Function 'CreateDataSour ce
<form id="Form1" method="post" runat="server">
<ul>
<asp:Repeater id="Repeater1" runat="server">
<HeaderTemplate >
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server"> My label</asp:Label>
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate >
<li>
<asp:Label id="Label3" runat="server">
<%# DataBinder.Eval (Container, "DataItem.Strin gValue") %>
</asp:Label>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</form>
"Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message
news:ca******** @kcweb01.netnew s.att.com... On my code behind page, how can I reference a Label control that's included in a Repeater?
In other words, given:
<asp:Repeater id="Repeater1" runat="server"> <HeaderTemplate > <table> <tr> <td><asp:Labe l ID="Label1" runat="server"> </asp:Label></td>
How can I reference Label1.Text in my VB code? (note that Label1 does not get repeated as it's in the header)
-- Tom Kaminski IIS MVP http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS http://mvp.support.microsoft.com/ http://www.microsoft.com/windowsserv...y/centers/iis/
Thanks.
I must be doing something wrong as when I use this code the repeater does
not render:
Dim myCtrl As Label = Repeater1.Contr ols(0).FindCont rol("Label1")
myCtrl.Text = "XXX"
If I comment those two lines out, it renders.
"Martin Marinov" <me********@mec rossroad.bg> wrote in message
news:uE******** ********@TK2MSF TNGP12.phx.gbl. .. if you want to use it from an event of that repeater such as ItemDataBound you can use : If e.Item.ItemType = ListItemType.He ader Then CType(e.Item.Co ntrols(0).FindC ontrol("Label1" ), Label).Text = "Something" End If if you want to access it from other method you can use:
Repeater1.Contr ols(0).FindCont rol("Label1")
Regards Martin
"Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message news:ca******** @kcweb01.netnew s.att.com... On my code behind page, how can I reference a Label control that's included in a Repeater?
In other words, given:
<asp:Repeater id="Repeater1" runat="server"> <HeaderTemplate > <table> <tr> <td><asp:Labe l ID="Label1" runat="server"> </asp:Label></td>
How can I reference Label1.Text in my VB code? (note that Label1 does
not get repeated as it's in the header)
-- Tom Kaminski IIS MVP http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS http://mvp.support.microsoft.com/ http://www.microsoft.com/windowsserv...y/centers/iis/
That's it! Thanks Ken.
"Ken Cox [Microsoft MVP]" <BA************ @sympatico.ca> wrote in message
news:Oa******** ******@TK2MSFTN GP11.phx.gbl... Hi Tom,
After you bind the repeater, you should be able to get it with
lblCntrl = Repeater1.Contr ols(0).FindCont rol("Label1")
Sample code below.
Ken
Private Sub Page_Load _ (ByVal sender As System.Object, _ ByVal e As System.EventArg s) _ Handles MyBase.Load Dim lblCntrl As Label Repeater1.DataS ource = CreateDataSourc e() Repeater1.DataM ember = "StringValu e" Repeater1.DataB ind() lblCntrl = Repeater1.Contr ols(0).FindCont rol("Label1") lblCntrl.Text = "The new text" End Sub Function CreateDataSourc e() As DataTable Dim dt As New DataTable Dim dr As DataRow dt.Columns.Add( New DataColumn _ ("IntegerValue" , GetType(Int32)) ) dt.Columns.Add( New DataColumn _ ("StringValu e", GetType(String) )) dt.Columns.Add( New DataColumn _ ("CurrencyValue ", GetType(Double) )) dt.Columns.Add( New DataColumn _ ("Boolean", GetType(Boolean ))) Dim i As Integer For i = 0 To 8 dr = dt.NewRow() dr(0) = i dr(1) = "Item " + i.ToString() dr(2) = 1.23 * (i + 1) dr(3) = (i = 4) dt.Rows.Add(dr) Next i Return dt End Function 'CreateDataSour ce
<form id="Form1" method="post" runat="server"> <ul> <asp:Repeater id="Repeater1" runat="server"> <HeaderTemplate > <table> <tr> <td> <asp:Label ID="Label1" runat="server"> My label</asp:Label> </td> </tr> </table> </HeaderTemplate> <ItemTemplate > <li> <asp:Label id="Label3" runat="server"> <%# DataBinder.Eval (Container, "DataItem.Strin gValue") %> </asp:Label> </li> </ItemTemplate> </asp:Repeater> </ul> </form>
"Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message news:ca******** @kcweb01.netnew s.att.com... On my code behind page, how can I reference a Label control that's included in a Repeater?
In other words, given:
<asp:Repeater id="Repeater1" runat="server"> <HeaderTemplate > <table> <tr> <td><asp:Labe l ID="Label1" runat="server"> </asp:Label></td>
How can I reference Label1.Text in my VB code? (note that Label1 does
not get repeated as it's in the header)
-- Tom Kaminski IIS MVP http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS http://mvp.support.microsoft.com/ http://www.microsoft.com/windowsserv...y/centers/iis/
What was the problem Tom ? are you cast the finded control to a label
control
Dim myCtrl As Label = CType(Repeater1 .Controls(0).Fi ndControl("Labe l1"),
Label)
Regards,
Martin
"Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message
news:ca******** @kcweb01.netnew s.att.com... That's it! Thanks Ken.
"Ken Cox [Microsoft MVP]" <BA************ @sympatico.ca> wrote in message news:Oa******** ******@TK2MSFTN GP11.phx.gbl... Hi Tom,
After you bind the repeater, you should be able to get it with
lblCntrl = Repeater1.Contr ols(0).FindCont rol("Label1")
Sample code below.
Ken
Private Sub Page_Load _ (ByVal sender As System.Object, _ ByVal e As System.EventArg s) _ Handles MyBase.Load Dim lblCntrl As Label Repeater1.DataS ource = CreateDataSourc e() Repeater1.DataM ember = "StringValu e" Repeater1.DataB ind() lblCntrl = Repeater1.Contr ols(0).FindCont rol("Label1") lblCntrl.Text = "The new text" End Sub Function CreateDataSourc e() As DataTable Dim dt As New DataTable Dim dr As DataRow dt.Columns.Add( New DataColumn _ ("IntegerValue" , GetType(Int32)) ) dt.Columns.Add( New DataColumn _ ("StringValu e", GetType(String) )) dt.Columns.Add( New DataColumn _ ("CurrencyValue ", GetType(Double) )) dt.Columns.Add( New DataColumn _ ("Boolean", GetType(Boolean ))) Dim i As Integer For i = 0 To 8 dr = dt.NewRow() dr(0) = i dr(1) = "Item " + i.ToString() dr(2) = 1.23 * (i + 1) dr(3) = (i = 4) dt.Rows.Add(dr) Next i Return dt End Function 'CreateDataSour ce
<form id="Form1" method="post" runat="server"> <ul> <asp:Repeater id="Repeater1" runat="server"> <HeaderTemplate > <table> <tr> <td> <asp:Label ID="Label1" runat="server"> My label</asp:Label> </td> </tr> </table> </HeaderTemplate> <ItemTemplate > <li> <asp:Label id="Label3" runat="server"> <%# DataBinder.Eval (Container, "DataItem.Strin gValue") %> </asp:Label> </li> </ItemTemplate> </asp:Repeater> </ul> </form>
"Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message news:ca******** @kcweb01.netnew s.att.com... On my code behind page, how can I reference a Label control that's included in a Repeater?
In other words, given:
<asp:Repeater id="Repeater1" runat="server"> <HeaderTemplate > <table> <tr> <td><asp:Labe l ID="Label1" runat="server"> </asp:Label></td>
How can I reference Label1.Text in my VB code? (note that Label1 does not get repeated as it's in the header)
-- Tom Kaminski IIS MVP http://www.iistoolshed.com/ - tools, scripts, and utilities for
running IIS http://mvp.support.microsoft.com/ http://www.microsoft.com/windowsserv...y/centers/iis/
Ken sorted it out, I need to bind the repeater first.
"Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message
news:ca******** @kcweb01.netnew s.att.com... Thanks.
I must be doing something wrong as when I use this code the repeater does not render: Dim myCtrl As Label = Repeater1.Contr ols(0).FindCont rol("Label1")
myCtrl.Text = "XXX"
If I comment those two lines out, it renders.
"Martin Marinov" <me********@mec rossroad.bg> wrote in message news:uE******** ********@TK2MSF TNGP12.phx.gbl. .. if you want to use it from an event of that repeater such as
ItemDataBound you can use : If e.Item.ItemType = ListItemType.He ader Then CType(e.Item.Co ntrols(0).FindC ontrol("Label1" ), Label).Text =
"Something" End If if you want to access it from other method you can use:
Repeater1.Contr ols(0).FindCont rol("Label1")
Regards Martin
"Tom Kaminski [MVP]" <tomk (A@T) mvps (D.O.T) org> wrote in message news:ca******** @kcweb01.netnew s.att.com... On my code behind page, how can I reference a Label control that's included in a Repeater?
In other words, given:
<asp:Repeater id="Repeater1" runat="server"> <HeaderTemplate > <table> <tr> <td><asp:Labe l ID="Label1" runat="server"> </asp:Label></td>
How can I reference Label1.Text in my VB code? (note that Label1 does not get repeated as it's in the header)
-- Tom Kaminski IIS MVP http://www.iistoolshed.com/ - tools, scripts, and utilities for
running IIS http://mvp.support.microsoft.com/ http://www.microsoft.com/windowsserv...y/centers/iis/
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kevin Cunningham |
last post by:
I have a repeater with some labels in it (code below). For whatever reason
the text for the label is not persisted in viewstate on the postback. Is
there a trick to get this to work? Is there something else I can do to get
the same visual effect (not using a datagrid :) )? This is annnooying!
<table>
<asp:repeater id="rptGunReadingsNew" runat="server">
<ItemTemplate>
<tr>
<td>
|
by: Shapper |
last post by:
Hello,
I have an Asp:Label inside the HeaderTemplate of an ASP:Repeater:
<asp:Repeater id="myRepeater" runat="server">
<HeaderTemplate>
<asp:Label id="title" runat="server"></asp:Label>
...
In my VB code I have:
Protected WithEvents title As System.Web.UI.WebControls.Label
|
by: Joel |
last post by:
Hey all-
I'm new to asp.net so please bear with me -- I'm attempting to
reference the repeater's Container.DataItem outside the repeater
object.
In other words -- In a seperate sub routine: if the repeater's
Container.DataItem == Something -> Do Action. How do I reference the
Container.DataItem in by sub routine (And thus outside the repeater
object)?
|
by: ST |
last post by:
Hello everyone, Can anyone help me with this error above when I debug my web
app project in vstudio.net?? I can't figure it out! It was working fine for
months, and now all of a sudden it's not!!
This is the error:
biopsy.searchsubject.btnSubject_Click(Object Sender, EventArgs e) in
C:\INetPub\WWWRoot\biopsy\searchsubject.aspx.vb:198
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
|
by: Groove |
last post by:
I have a typical Repeater that contains a Template (html table). The
repeater / template lists many records and in the footer, I'd like to simply
SUM up the $$ amounts from all the records in the repeater. Easy enough.
So I tried to place a Label control in the footer and fill the Text of the
label from code. I get the label is not declared error. So how can I go
about doing this? I tried writing a helper function in the code-behind...
| |
by: sck10 |
last post by:
Hello,
How do you reference a label inside a repeater? I tried the following and
got the error:
Object reference not set to an instance of an object.
((Label)this.rptRSS.FindControl("lblRSSFeed")).Text = "My Value";
|
by: rn5a |
last post by:
Consider the following code:
<script runat="server">
Sub ShowData(obj As Object, ea As EventArgs)
lblDate.Text = DateTime.Now.ToString("d")
lblDate.DataBind()
End Sub
</script>
<form runat="server">
<asp:Label ID="lblDate" OnDataBinding="ShowData" runat="server"/>
|
by: sck10 |
last post by:
Hello,
I am using the following Repeater control. How do I reference the label
"lblCurrentYr"?
Thanks, sck10
<asp:Repeater id="rptCustomerRevenue" runat="server">
<HeaderTemplate>
|
by: =?Utf-8?B?RXJpY2E=?= |
last post by:
I think I know what my problem is , but I don't know how to correct it. So,
if anyone could help, I would be very grateful. I am using the
PagedDataSource class to implement paging in a repeater control. On the
repeater I have a label named lblCurrentPage. The label is supposed to
display the page number out of the total number of pages. The label is within
the repeater control in the Header Template. The exception is thrown on the
line...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |