【问题标题】:How do I change the Control in a Specific field when the Gridview Control is in edit mode in my Dynamic Data site?当 Gridview 控件在我的动态数据站点中处于编辑模式时,如何更改特定字段中的控件?
【发布时间】:2011-10-31 09:41:07
【问题描述】:

在 List.aspx 页面上,我自定义了带有名称的列。我已经自动生成了删除、编辑和选择按钮为真。但是,当 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>

【问题讨论】:

    标签: asp.net gridview dynamic-data


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2014-03-02
      • 1970-01-01
      • 2011-07-04
      • 1970-01-01
      • 2012-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多