当 Gridview 控件在动态数据站点中处于编辑模式时,如何更改特定字段中的控件?

发布于 2024-12-12 16:55:13 字数 2924 浏览 2 评论 0原文

在 List.aspx 页面上,我自定义了带有名称的列。我已将删除、编辑和选择按钮自动生成为 true。但是,当 GridView 处于行编辑模式时,在一个字段上的 CA_AgencyAcronym 字段上,我希望将该字段作为下拉列表而不是像现在这样的文本框。我该如何实现这个目标?我已经在我的字段模板目录中创建了自定义用户控件。

<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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掌心的温暖 2024-12-19 16:55:17

您可以自定义 gridView 的 EditItemTemplate 并将下拉控件替换默认文本框。尝试右键单击 GridView,然后选择编辑模板...

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文