asp.net - How to do a count on table's <tr> and make some andother background-color in vb.net -
in asp.net i'm having in frontend, , in backend(vb) want count on <tr>
's on page , every other (so 2nd, 4th, 6th,...) has have background color.
how count <tr>
's on page , how can tell them give every other 1 background-color?
this frontend:
<p class="title"><asp:label id="label1" runat="server" text="title 1"></asp:label></p> <table class="table"> <tr><td>person 1</td><td>bestuurder</td></tr> <tr><td>person 2</td><td>zaakvoerder</td></tr> </table> <p class="title"><asp:label id="label3" runat="server" text="title 2"></asp:label></p> <asp:button id="btn_add_beheerder" runat="server" text="beheerder toevoegen" class="btn_add"/> <table class="table"> <tr><td>person 3</td><td>beheerder</td></tr> <tr><td>person 4</td><td>beheerder</td></tr> </table>
the backend going on page_load. think best way putting every <tr>
in array , every array[i]
that's dividable 2 give background-color? best way work?
you of course in gazillion different ways. here 1 suggestion.
<asp:gridview id="gv" runat="server" datasourceid="ds"> <columns> <asp:boundfield datafield="person" /> <asp:boundfield datafield="something else"/> </columns> <alternatingrowstyle backcolor="blue" /> </asp:gridview> <asp:sqldatasource runat="server" id="ds" connectionstring="your connectionstring" selectcommand="--select stuff"> </asp:sqldatasource>
note "alternatingrowstyle"
Comments
Post a Comment