开发者

C# WEb App Listview formatting

开发者 https://www.devze.com 2023-03-22 06:02 出处:网络
Building a web app here and I would like to be able to alternate my listeview rows. Can someone give me some sample code to achieve this? The 3 standard ones in VS2010 sucks and I\'d like to be able t

Building a web app here and I would like to be able to alternate my listeview rows. Can someone give me some sample code to achieve this? The 3 standard ones in VS2010 sucks and I'd like to be able to give it something that goes along with the scheme of my webapp. Row 1= blue, 开发者_高级运维2=gray, 3=blue, etc. Something to that effect.

Thanks


Set the colors in your templates:

Edited To Add I would imagine the header is built in the LayoutTemplate, so you can bold them there (see the code I added). You'll probably want to use CSS - define the various styles you need in a separate CSS file as classes, and assign the classes where needed to save excess typing.

<asp:ListView id="ListView1" runat="server">
  <LayoutTemplate>
      <table>
          <tr>
              <td style="font-weight:bold;">header</td>
              <td style="font-weight:bold;">header</td>
          </tr>
          <asp:PlaceHolder id="itemPlaceHolder" runat="server" />
      </table>
  </LayoutTemplate>
  <ItemTemplate>
    <tr style="background-color:blue;">
        <td></td>
    </tr>
  </ItemTemplate>
  <AlternatingItemTemplate>
     <tr style="background-color:gray;">
         <td></td>
     </tr>
  </AlternatingItemTemplate>
</asp:ListView>

I've abbreviated the code considerably, but it should get you going where you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消