Let me try to explain my situation. I have a database table which contains, among other things, a boolean column called PermissionSlipRequired. I have a repeater on my page, and before each row in the database is shown in the repeater, I want to use my code behind to check the value of PermissionSlipRequired. Based on whether the value of PermissionSlipRequired is true or false, I want to change the text of a literal within the repeater. That's a real mouthful, hopefully some markup and code will clarify. Here's my repeater:

<asp:Repeater ID="PermissionSlipRepeater" runat="server" 
            DataSourceID="EventsSqlDataSource">
            <ItemTemplate><p class="ModuleContent"><span class="InlineTitle"><%# Eval("Title")%></span><br />
                <asp:Literal ID="PermissionSlipLiteral" runat="server"></asp:Literal></p>
            </ItemTemplate>

Recommended Answers

All 3 Replies

on ItemDataBound Event you can change wotever you want...!

on ItemDataBound Event you can change wotever you want...!

Not exactly sure what dnanetwork means ... anyway, here's the code I managed to come up with to do what I wanted:

Protected Sub PermissionSlipRepeater_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles PermissionSlipRepeater.ItemDataBound
        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
            Dim PermissionSlipLiteral As Literal = e.Item.FindControl("PermissionSlipLiteral")
            Dim CurrentRowDataRowView As System.Data.DataRowView = e.Item.DataItem

            If CurrentRowDataRowView.Row("PermissionSlipRequired") = True Then
                PermissionSlipLiteral.Text = "Permission slip required"

            End If
        End If
    End Sub

that's wot i've suggested...and that's wot u have done..

this is a common technique of solving this problem.

there is one more..find it if you can.. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.