Search code examples
asp.netcssstylesdatalistdatalistitem

asp.net datalist - change styling


<asp:DataList ID="ItemsList" RepeatDirection="Vertical" runat="server">            
  <ItemTemplate>                  
        <asp:LinkButton 
            ID="SecondLevelItem" runat="server"  CommandName="second" 
            OnCommand="SecondLevelItem_Onclick" CommandArgument="<%# Container.DataItem %>" 
            Text="<%# Container.DataItem %>" >  
        </asp:LinkButton>                                     
    </ItemTemplate>            
 </asp:DataList>

everything works fine. except that I do not have any control over the styling on the items. I mean I have the styling on the datalist externally but I want to add some spacing (vertically) between each item. How do I do tht? Thanks


Solution

  • In general, to control style, you can apply the <ItemStyle> tag inside the <asp:DataList>.

    You can optionally inject CSS properties into the asp:LinkButton tag, either with the class attribute or directly with style, controlling the height or other CSS properties.

    If it's applicable, you can still add a
    on the bottom of the template (but this will add a vertical space to the last item too, and I don't know if you want it).

    Hope to have been of help.