ASPx GridView Edit Template with dropDown

Posted on 2009-04-16
Last Modified: 2012-05-06
I want to be able to put a drop down box in an editable datagrid, Ive managed to get a dropdown box, and with the values, but when I click on 'update' it doesnt update the row in the database. and doesnt show the value of the field as the selected item in the drop down. I know I havnt set it, but dont know how to set it.

Any ideas?

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 

        DataKeyNames="priID" DataSourceID="SqlDataSource1" 

        EmptyDataText="There are no data records to display.">


            <asp:CommandField ShowEditButton="True" />

            <asp:BoundField DataField="priID" HeaderText="priID" ReadOnly="True" 

                SortExpression="priID" />

            <asp:BoundField DataField="Username" HeaderText="Username" 

                SortExpression="Username" />

            <asp:BoundField DataField="Password" HeaderText="Password" 

                SortExpression="Password" />

            <asp:BoundField DataField="PhoneNo" HeaderText="PhoneNo" 

                SortExpression="PhoneNo" />

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

            <asp:BoundField DataField="Company" HeaderText="Company" 

                SortExpression="Company" />

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


                    <asp:DropDownList ID="StartingDir" runat="server" 





                        <asp:ListItem Enabled="True" Selected="True">Please Select</asp:ListItem>


                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 

                        ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString1 %>" 

                        SelectCommand="SELECT directory FROM Directories"></asp:SqlDataSource>



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



            <asp:CheckBoxField DataField="AllowUpload" HeaderText="AllowUpload" 

                SortExpression="AllowUpload" />



Open in new window

Question by:tonelm54

    Author Comment

    LVL 29

    Accepted Solution

    Hi tonelm54,
    Can i see you update statement? You can check on GridView's RowCommand event and perform the update parameters accordingly. Then, proceed the GridView's RowUpdating event to update the datasource. That should did the trick.

    GridView's RowCommand

    GridView's RowUpdating

    More details:


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now