Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8630337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:02:21+00:00 2026-06-12T09:02:21+00:00

How can I put a drop down list in a DetailView control? I have

  • 0

How can I put a drop down list in a DetailView control? I have converted the field into template but having some issues when I add the drop down list, basically it is not binding the data into my table. I simply want to have some static data in the drop down but it should save it when I hit the Update button. I have the DetailView in a Edit mode. Thanks

<asp:DetailsView ID="DetailsView2" runat="server" AutoGenerateRows="False" 
            BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" 
            CellPadding="4" CellSpacing="2" DataKeyNames="Post_ID" 
            DataSourceID="MyDataSource" ForeColor="Black" Height="50px" 
            Width="805px" DefaultMode="Edit">
            <EditRowStyle BackColor="#FFFFCC" Font-Bold="True" ForeColor="#003366" 
                BorderStyle="Groove" />
            <Fields>
                <asp:BoundField DataField="Post_ID" HeaderText="ID" ReadOnly="True" 
                    SortExpression="Post_ID" />
                <asp:TemplateField HeaderText="Category" 
                    SortExpression="CategoryList">



                     <EditItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" 
                            Text='<%# Bind("CategoryList") %>'
                            Height="20px" Width="250px"></asp:TextBox>
                    </EditItemTemplate>




                      <InsertItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" 
                            Text='<%# Bind("CategoryList") %>'
                            Height="20px" TextMode="MultiLine" Width="300px"></asp:TextBox>
                    </InsertItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("CategoryList") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>


 <asp:TemplateField ShowHeader="False">
                    <EditItemTemplate>
                        <asp:Button ID="Button1" runat="server" CausesValidation="True" 
                            CommandName="Update" Text="Update" />
                        &nbsp;<asp:Button ID="Button2" runat="server" CausesValidation="False" 
                            CommandName="Cancel" Text="Cancel" />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Button ID="Button1" runat="server" CausesValidation="False" 
                            CommandName="Edit" Text="Edit" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Fields>
            <FooterStyle BackColor="#CCCCCC" />
            <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
            <InsertRowStyle BackColor="#FFFFCC" />
            <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
            <RowStyle BackColor="White" />
        </asp:DetailsView> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:02:23+00:00Added an answer on June 12, 2026 at 9:02 am

    You can try with

        <EditItemTemplate>
            <asp:DropDownList ID="DropDownList2" Runat="server"   >
               <asp:ListItem>1</asp:ListItem>
               <asp:ListItem>2</asp:ListItem>
            </asp:DropDownList>
         </EditItemTemplate>
    

    Code Behind

    protected void dvItem_DataBound(object sender, EventArgs e)
    {
        if (this.dvItem.CurrentMode == DetailsViewMode.Edit)
        {
           DropDownList control= (DropDownList)this.dvItem.FindControl("IdDDL");
           ..          
        }
    }  
    

    Selection

    protected void dvItem_ItemInserting(object sender, DetailsViewInsertEventArgs e)
    {
           DropDownList control = (DropDownList)this.dvItem.FindControl("IdDDL");
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a drop down list. I have it working but
I have a working simple jquery drop-down menu . But problem is how can
I'm having trouble binding the selected value of a drop down list to the
I have a drop-down list with known values. What I'm trying to do is
In my application, users have a list of items that they can put in
How can I add a data to my drop down list came from database?
I have a Model, which has a drop down list of reference data. The
I'm trying to understand when I can put certain objects into a users session
I put a dropdownlist on a webform and give a list as datasource. But
Is it possible to have multiple drop down lists in asp.net mvc? What I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.