EditItemTemplate dropdown list

Rate It (1)

Last post 11-08-2007 12:59 PM by RTisserand. 1 replies.

Sort Posts:

  • EditItemTemplate dropdown list

    11-08-2007, 10:41 AM
    • Loading...
    • RTisserand
    • Joined on 11-05-2007, 10:46 AM
    • Posts 18

    I have followed the instructions at http://msdn2.microsoft.com/en-us/library/ms178294(VS.80).aspx to add a DropDownList in an EditItem Template.  The instructions were easy to follow, but I am running into one problem.  When open the EditItem template and the dropdown list is at the top of the template instead of next to the binded text box field.  I did select Two-way databinding and made sure to follow the instructions exactly.  Could someone please tell me how to have my dropdown show up next to its binded field?  Here is my code and thanks for any help.

    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" BackColor="White"

    BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4"

    DataKeyNames="StaffID" DataSourceID="ObjectDataSource1" GridLines="Horizontal"

    Height="50px" Style="z-index: 100; left: 169px; position: absolute; top: 56px"

    Width="271px">

    <FooterStyle BackColor="White" ForeColor="#333333" />

    <RowStyle BackColor="White" ForeColor="#333333" />

    <PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />

    <Fields>

    <asp:BoundField DataField="StaffID" HeaderText="StaffID" InsertVisible="False" ReadOnly="True"

    SortExpression="StaffID" />

    <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />

    <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />

    <asp:BoundField DataField="ComputerName" HeaderText="ComputerName" SortExpression="ComputerName" />

    <asp:BoundField DataField="Ext" HeaderText="Ext" SortExpression="Ext" />

    <asp:BoundField DataField="Mobile" HeaderText="Mobile" SortExpression="Mobile" />

    <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />

    <asp:TemplateField HeaderText="Department" SortExpression="Department">

    <EditItemTemplate>

    &nbsp;

    <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="ObjectDataSource2"

    DataTextField="Department" DataValueField="Department"

    SelectedValue='<%# Bind("Department") %>' Style="z-index: 100; left: 0px; position: absolute;

    top: 0px">

    </asp:DropDownList>

    <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" OldValuesParameterFormatString="original_{0}"

    SelectMethod="DepartmentList" TypeName="ActiveStaffTableAdapters.DepartmentListTableAdapter">

    </asp:ObjectDataSource>

    &nbsp;&nbsp;

    </EditItemTemplate>

    <InsertItemTemplate>

    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Department") %>'></asp:TextBox>

    </InsertItemTemplate>

    <ItemTemplate>

    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Department") %>'></asp:Label>

    </ItemTemplate>

    </asp:TemplateField>

    <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />

    <asp:CheckBoxField DataField="Active" HeaderText="Active" SortExpression="Active" />

    <asp:CommandField ShowEditButton="True" />

    </Fields>

    <HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />

    <EditRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />

    </asp:DetailsView>

  • Re: EditItemTemplate dropdown list

    11-08-2007, 12:59 PM
    Answer
    • Loading...
    • RTisserand
    • Joined on 11-05-2007, 10:46 AM
    • Posts 18

    I was able to resolve my own problem.  I found that when your in the Edit Templates smart tag that there is a section for every field that you have converted to a template field.  Each converted template field had its own item, insertitem, and edit item settings.

Page 1 of 1 (2 items)
Microsoft Communities
Page view counter