|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Datalist formatting questionsIs there a way to:
1.) Set the backcolor of so the first cell in each column is same and then alternate from there? such as the example of repeatColumns = "3" below. Otherwise, checking the alternatingitem won't work. blue blue blue white white white blue blue blue etc. 2.) Put a "spacer" column between each column to spread them out a litte? Thanks, Dave. Yes, the key is to make the number of cells divisible by the right number.
Here is the code that I used when I created the collection I used that had three columns: Dim temppoems As SortedList = Global.GetPoems() Dim poemcollection As New Collection For Each poem As DictionaryEntry In temppoems poemcollection.Add(poem.Key) Next While (poemcollection.Count Mod 6) <> 0 poemcollection.Add("") End While datPoems.DataSource = poemcollection datPoems.DataBind() Notice that the While loop adds null values to poemcollection until it is divisible by 6. 6 is the number used in this situation because it is 2*3. The DataList tag and the Template tags inside it are the same as they would usually be, here is the one that I used: <asp:datalist id="datPoems" runat="server" BorderWidth="2px" BorderColor="Black" RepeatColumns="3"> <HeaderTemplate> <asp:Label id="lblPoems" runat="server" Font-Size="X-Large">Poems</asp:Label> </HeaderTemplate> <AlternatingItemStyle Wrap="False" BackColor="White"></AlternatingItemStyle> <ItemStyle Wrap="False" BackColor="Silver"></ItemStyle> <ItemTemplate> <asp:HyperLink id="lnkPoem1" runat="server" style="padding-right:15px;padding-left:15px;" Text='<%# DataBinder.Eval(Container, "DataItem") %>' NavigateUrl='<%# "viewpoem.aspx?poem=" & Server.UrlEncode(Container.DataItem) %>'></asp:HyperLink> </ItemTemplate> <HeaderStyle Font-Names="Arial,Helvetica,Sans-Serif" Font-Bold="True" BackColor="#A080C0"></HeaderStyle> <AlternatingItemTemplate> <asp:HyperLink id="lnkPoem2" runat="server" style="padding-right:15px;padding-left:15px;" Text='<%# DataBinder.Eval(Container, "DataItem") %>' NavigateUrl='<%# "viewpoem.aspx?poem=" & Server.UrlEncode(Container.DataItem) %>'></asp:HyperLink> </AlternatingItemTemplate> </asp:datalist> If you want to see the results of this code, go to my website at http://www.nathansokalski.com/poetry/index.aspx (Because you might not have a number of items exactly divisible by 6, the While loop might add up to 5 blank cells depending on how many items you have in your DataSource, the number of poems on my list just happens to currently be a multiple of 6). If you have any questions, feel free to ask. Good Luck! Show quoteHide quote "Dave" <D***@discussions.microsoft.com> wrote in message news:D4BEB23A-8A09-43B6-BC3F-D118F71A2FEB@microsoft.com... > Is there a way to: > > 1.) Set the backcolor of so the first cell in each column is same and then > alternate from there? such as the example of repeatColumns = "3" below. > Otherwise, checking the alternatingitem won't work. > > blue blue blue > white white white > blue blue blue > etc. > > 2.) Put a "spacer" column between each column to spread them out a litte? > > Thanks, Dave.
GridView w/ ObjectDataSource w/ Business object layer
GridView, ObjectDataSOurce, and enum parameter for select Web UserControl (ascx) and UrlProperty attribute Cant get user-entered values in GridView Scrolling DG w/a Fixed Header DataGrid1.DataSource = ds.Tables(2) Treeview SelectedNodeChanged event not firing GridView Multiple Select Buttons Stylesheet and CheckBoxList Looking for "search result" control |
|||||||||||||||||||||||