简体   繁体   中英

ASP.NET datalist question

I have made some progress with the DataList and UserControl this morning but I still try to figure out how I could improve my code (everything work but the GUI is not yet what desired).

In the ASPX file I have something like that :

    <asp:DataList ID="dlSpeechBubble" runat="server">
        <ItemTemplate>
            <CSVSMS:Bubble ID="singleSpeechBubble" runat="server" CurrentDataItem="<%# Container.DataItem %>"/>
        </ItemTemplate>
    </asp:DataList>

Every object bind well but the problem is that I need the user control to act differently depending of the value of the previous Data is compared to its value.

Where in ASP.NET does the logic between item goes? In PHP I would have do a loop and check with an index -1 and compare value... but how can I do it in ASP.NET?

Datalist does have events like ItemCreated and ItemDataBound that you can code to in the code behind.

If I understand correctly you want to modify an item based on a previous item? Why not create a user control which is populated from a DataTable or DataSet - adding each control to a placeholder on your page? That way you can use your loop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM