如何以编程方式为详细信息视图中的每个下拉列表控件添加以下模板字段?
<asp:TemplateField HeaderText="Your Gender">
<EditItemTemplate>
<asp:DropDownList ID="ddlGender" runat="server"
DataSourceid="ddlDAGender"
DataTextField="Gender" DataValueField="GenderID"
SelectedValue='<%#Bind("GenderID") %>'
>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate >
<asp:Label Runat="server" Text='<%# Bind("Gender") %>' ID="lblGender"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
答案 0 :(得分:0)
可能是这样的:
Dim tc As New System.Web.UI.WebControls.TemplateField
tc.HeaderTemplate = Page.LoadTemplate("Controls/DatagridCheckboxColumnHeader.ascx")
tc.ItemTemplate = Page.LoadTemplate("controls/DatagridCheckboxColumn.ascx")
tc.HeaderText = "Select"
grdView.Columns.Insert(0, tc)