当 Gridview 控件在动态数据站点中处于编辑模式时,如何更改特定字段中的控件?
在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以自定义 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...