Search code examples
asp.netgridviewdynamic-data

How do I change the Control in a Specific field when the Gridview Control is in edit mode in my Dynamic Data site?


On the List.aspx page I have customized the columns with names. And I have auto generated the delete, edit, and select buttons to true. However on one field the CA_AgencyAcronym field when the GridView is in in line edit mode I want to have that field as a Dropdownlist instead of a text box as it is now. How do I accomplish this? I have already created the custom user control in my field templates directory.

<asp:GridView ID="GridView1" runat="server" DataSourceID="GridDataSource" EnablePersistedSelection="true"
            AllowPaging="True" AllowSorting="True" CssClass="DDGridView"
            RowStyle-CssClass="td" HeaderStyle-CssClass="th" CellPadding="6" AutoGenerateColumns="false" AutoGenerateEditButton="true" AutoGenerateSelectButton="true" AutoGenerateDeleteButton="true">
            <Columns>                    
               <asp:DynamicField DataField="CA_AgencyName" HeaderText="Agency Name" />
                <asp:DynamicField DataField="CA_AgencyAcronym" HeaderText="Official Acronym"/>
                <asp:DynamicField DataField="CA_AgencyAcronym_SOLID" HeaderText="SOLID Acronym"/>
                <asp:DynamicField DataField="CA_AgencyHomePageURL" UIHint="Url" HeaderText="Web Address"/>
                <asp:DynamicField DataField="CA_AgencyContact" HeaderText="Email/Contact Page"/>
                <asp:DynamicField DataField="CA_AgencyCredentialType" HeaderText="Credential Type"/>
                <asp:DynamicField DataField="CA_AgencyStreetAddress1" HeaderText="Address"/>
                <asp:DynamicField DataField="CA_AgencyStreetAddress2" HeaderText="Address Cont."/>
                <asp:DynamicField DataField="CA_AgencyCity" HeaderText="City"/>
                <asp:DynamicField DataField="CA_AgencyState" HeaderText="State"/>
                <asp:DynamicField DataField="CA_AgencyZip" HeaderText="Zip"/>
                <asp:DynamicField DataField="CA_AgencyCountry" HeaderText="Country" />
                <asp:DynamicField DataField="CA_AgencyPhonePrimary" HeaderText="Primary Phone"/>
                <asp:DynamicField DataField="CA_AgencyPhonePrimaryExtension" HeaderText="Primary Extension"/>
                <asp:DynamicField DataField="CA_AgencyPhoneSecondary" HeaderText="Secondary Phone"/>
                <asp:DynamicField DataField="CA_AgencyRecordAddedUserID" HeaderText="Added By"/>
                <asp:DynamicField DataField="CA_AgencyRecordUpdatedDate" HeaderText="Date Changed"/>
                <asp:DynamicField DataField="CA_AgencyRecordUpdatedUserID" HeaderText="Changed By"/>
                <asp:DynamicField DataField="DOL_ORG_ID" HeaderText="DOL ORG ID"/>
            </Columns>

            <PagerStyle CssClass="DDFooter"/>        
            <PagerTemplate>
                <asp:GridViewPager runat="server" />
            </PagerTemplate>
            <EmptyDataTemplate>
                There are currently no items in this table.
            </EmptyDataTemplate>
        </asp:GridView>

Solution

  • You could customize the EditItemTemplate of your gridView and put your dropDown control replacing the default textbox. try with a right click on the GridView then select edit template...