Search code examples
asp.netcssdetailsview

Is It Possible To Display DetailsView Inline


That's it, really. I have a DetailsView and a button on my ASP.NET page, and the button always appears beneath the DetailsView. Using floating DIVs breaks things in other ways, so is there any method to suppress the line break after the DetailsView, and have it display inline with the button?

I've tried applying Display:Inline CSS to the DetailsView, but it didn't work.

EDIT - CODE ADDED BELOW

<asp:DetailsView ID="dvPremisesYardName" runat="server" datasourceid="SQLGeneralDetails" DefaultMode="Edit" AutoGenerateRows="False" FieldHeaderStyle-CssClass="fieldtitleyardname" 
    GridLines="None" onchange="hideControl('imgGeneralDetailsTick');"  >
    <Fields>
        <asp:TemplateField HeaderText="Yard Name">
            <EditItemTemplate>
                <asp:DropDownList ID="ddlPremisesYardName" runat="server" DataSourceID="SQLPremisesLookup" DataTextField="PremisesYardName" DataValueField="PremisesID" AutoPostBack="True" 
                    SelectedValue='<%# Bind("AdmissionPremisesID")%>' AppendDataBoundItems="True"  >
                    <asp:ListItem Text="Unknown" Value="" />
                </asp:DropDownList>                                                    
            </EditItemTemplate>
        </asp:TemplateField>
    </Fields>
</asp:DetailsView>
<asp:Button ID="btnPremisesAdd" runat="server" Text="Add New Premises" />
<asp:Button ID="btnPremisesEdit" runat="server" Text="Edit"  />

Screenshot


Solution

  • As you stated, you do not want to use float div. The easiest way will be to use table.

    Although we do not like to use table for page layout, I cannot think of other solution.

    <table>
      <tr>
        <td><asp:DetailsView .../></td>
        <td><asp:Button.../></td>
        <td><asp:Button.../></td>
      </tr>
    </table>