【发布时间】:2011-03-29 08:16:06
【问题描述】:
如前所述,我正在尝试做this。我发现的唯一区别是上面代码中包含的附加列表项。
我尝试使用AppendDataBoundItems=true,但它仍然无法正常工作。我还想将其默认值设置为在 itemtemplate 的标签中显示的值,即 DropDownList 的 SelectedValue='<%# Eval("DepartmentName") %>' 但下拉列表中的属性对我不可用。
可能是什么原因。 ??
<EditItemTemplate>
<asp:DropDownList ID="ddlDepartment_Edit" runat="server"
DataSourceID="dsDepartment_Edit" DataTextField="DepartmentName"
DataValueField="PK_DepartmentId">
</asp:DropDownList>
<asp:SqlDataSource ID="dsDepartment_Edit" runat="server"
ConnectionString="<%$ ConnectionStrings:BlackHillsConnect %>"
ProviderName="System.Data.SqlClient" SelectCommand="sp_GetDepartmentDropDown"
SelectCommandType="StoredProcedure">
</asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblDepartmentName" runat="server" Text='<%# Eval("DepartmentName") %>' >
</asp:Label>
</ItemTemplate>
我正在使用GridView
【问题讨论】:
标签: c# asp.net data-binding sqldatasource