I use the ItemDatBound in my grids to manipulate stuff.
I assume you can do the same for a Repeater.
=============== =============== =============
Sample code:
=============== =============== =============
Private Sub dg1_ItemDataBou nd(ByVal sender As System.Object, ByVal e As
DataGridItemEve ntArgs) Handles dg1.ItemDataBou nd
If e.Item.ItemType = ListItemType.He ader Then
'do something to the header
End If
If e.Item.ItemType = ListItemType.It em OrElse e.Item.ItemType =
ListItemType.Al ternatingItem Then
'need to take paging into account!
Dim mIndex As Integer = CType(sender, DataGrid).PageS ize *
CType(sender, DataGrid).Curre ntPageIndex + e.Item.ItemInde x
'set Status hyperlink
Dim oHylStatus As HyperLink = CType(e.Item.Fi ndControl("hylS tatus"),
HyperLink)
If mCollection(mIn dex).statustext = "None" Then
oHylStatus.Navi gateUrl = ""
Else
oHylStatus.Navi gateUrl = "javascript
:..; "
End If
oHylStatus.Text = mCollection(mIn dex).statustext
If mCanAmend=True Then
Dim oBtnAmend As ImageButton = CType(e.Item.Fi ndControl("btnA mend"),
ImageButton)
If mCollection(mIn dex).status = "XYZ" Then
oBtnAmend.Visib le = True
Else
oBtnAmend.Visib le = False
End If
End If
End If
End Sub
--
Joe Fallon
"Bennett Haselton" <be*****@peacef ire.org> wrote in message
news:e6******** *************** ***@posting.goo gle.com...
If I have this code for repeater, it gives a compilation error saying
"The type or namespace name 'MyValue2' could not be found":
<asp:Repeater id="MyList" runat="server">
<ItemTemplate >
<%#Container.Da taItem%><br>
<% MyValue2.Text = "ghi"; %>
<asp:TextBox ID="MyValue2" Runat="server"/>
<br>
</ItemTemplate>
</asp:Repeater>
Presumably that's because the MyValue2 control is inside an
ItemTemplate that gets repeated multiple times, so each instance of
MyValue2 gets a unique ID when the page is actually rendered, and the
C# code can't find the "MyValue2" because they were given a series of
unique names instead. (In fact I can even see their IDs in the source
code of the rendered page -- MyList__ctl0_My Value2,
MyList__ctl1_My Value2, etc.)
So, is there a way to have inline code inside the ItemTemplate that
can modify a control that's also repeated inside the template?
I have four ASP.Net books and I can't find any examples in any of them
showing how to do this... Maybe it can't be done?
-Bennett