I have two ListViews in an E-开发者_JAVA技巧Commerce store, one for the products and one for the cart. I'm adding products for the cart with a LinkButton CommandName in the products ListView. Each time I add a product (row) to the cart I'm getting a double border between the rows.
So I have set the CSS for the top, left and right borders only, in my CSS style sheet. What I want to do is add the bottom border programmatically in the code-behind. Do I do this in the ItemCreated handler and what syntax would I use?
Set your border-bottom via your existing class, then add a new class to RowIndex 0 and set your border-top property for the new class.
In the ItemTemplate:
<tr class='<%# (Container.DataItemIndex == 0 ? " ClassName" : null) %>'>
It's probably easier to tell when you're on the first element and add a top bar than tell when you're on the last element and add a bottom bar. You could put a private class variable starts out set to True
. Then in your ItemDataBound event, if the variable is true, add a first
or something class to the element and set the variable to False
so every other element will skip over the code.
精彩评论