<ItemTemplate>
<asp:DropDownList ID="DDLDepotCategory" runat="server"
DataSourceID="SqlDataSource1" DataTextField="DepotCategory"
DataValueField="DepotCategory"
SelectedValue='<%# DataBinder.Eval(Container.DataItem,"DepotCategory") %>'>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ETHANConnectionString %>"
SelectCommand="SELECT [DepotCategory] FROM [DepotCategory]">
</asp:SqlDataSource>
</ItemTemplate>protected void RawDataBind()
{
if (!IsPostBack)
{
dt.Columns.Add("DepotCategory");
dt.Columns.Add("Notes");
for (int i = 0; i < 3; i++)
{
DataRow dr = dt.NewRow();
dt.Rows.Add(dr);
}
this.GVStorage.DataSource = dt;
this.GVStorage.DataBind();
}
}代码是一样的 在test里写好了 复制到其他页面上
就出现
“DDLDepotCategory”有一个无效 SelectedValue,因为它不在项目列表中。
参数名: value后来干脆重新绑定 datasource 还是一样!!
<asp:DropDownList ID="DDLDepotCategory" runat="server"
DataSourceID="SqlDataSource1" DataTextField="DepotCategory"
DataValueField="DepotCategory"
SelectedValue='<%# DataBinder.Eval(Container.DataItem,"DepotCategory") %>'>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ETHANConnectionString %>"
SelectCommand="SELECT [DepotCategory] FROM [DepotCategory]">
</asp:SqlDataSource>
</ItemTemplate>protected void RawDataBind()
{
if (!IsPostBack)
{
dt.Columns.Add("DepotCategory");
dt.Columns.Add("Notes");
for (int i = 0; i < 3; i++)
{
DataRow dr = dt.NewRow();
dt.Rows.Add(dr);
}
this.GVStorage.DataSource = dt;
this.GVStorage.DataBind();
}
}代码是一样的 在test里写好了 复制到其他页面上
就出现
“DDLDepotCategory”有一个无效 SelectedValue,因为它不在项目列表中。
参数名: value后来干脆重新绑定 datasource 还是一样!!
自己动手在客户端,或者是服务段实现一下吧。