views:

270

answers:

1

I have a DataList, which is set to Horizontal Flow which renders a set of checkboxes. I also have a drop down list, which I would like to be rendered at the end of the datalist, on the same line as the last time in the datalist.

Is it possible to get rid of the last line break at the end of the datalist so the dropdown does not render on the line below the datalist?

[] i1 [] i2 [] i3 [] i4
[] i5 [] i6 DropDownList
A: 

I'm afraid not. The rendering code for the RepeatInfo (which is used to render the DataList) explicitly writes a line break when a layout it set to horizontal flow and an item is on a column boundary or the last in the list. Here that part of code:

private void RenderHorizontalRepeater(HtmlTextWriter writer, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
{
    ...
    if (indexInColumn == repeatColumns || itemIndex == repeatedItemCount - 1)
    {
        if (isTableLayout)
        {
            writer.RenderEndTag();
        }
        else if (repeatColumns < repeatedItemCount)
        {
            if (this.EnableLegacyRendering)
            {
                writer.WriteObsoleteBreak();
            }
            else
            {
                writer.WriteBreak();
            }
        }
        indexInColumn = 0;
    }
}

I suppose you could try to inject the drop down list into a control collection when an item is created or bound, but then you'd have to know that it a last one. This requires knowing total count upfront, before you do the data bind.

Ruslan
Thanks, in the end I took out the number of columns attribute in the datalist and added a literal with a line break within ItemDataBind on the nth ItemIndex
HadleyHope