我在网格视图中有一个下拉列表。这是网格视图
<asp:GridView ID="gvFabricDetails" runat="server" AutoGenerateColumns="False" ShowFooter="True" CellPadding="4" ForeColor="#333333" GridLines="None" Width="49px" onrowdatabound="gvFabricDetails_RowDataBound" >
<Columns>
<asp:TemplateField HeaderText="Programme">
<ItemTemplate>
<asp:DropDownList ID="ddlProgramme" DataTextField="PROGRAMME_NAME" DataValueField="PROGRAMME_ID" SelectedValue='<%# Bind("PROGRAMME") %>' AppendDataBoundItems="true" runat="server"></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Lot/Style">
<ItemTemplate>
<asp:TextBox ID="txtLot" TabIndex="2" Text='<%# Bind("LOT_STYLE") %>' runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Art#">
<ItemTemplate>
<asp:TextBox ID="txtArt" TabIndex="3" Text='<%# Bind("ART") %>' runat="server" ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</asp:GridView>
这是绑定数据的代码
public DataTable loadFabricInfos()
{
DataTable dt = new DataTable();
string sql = "";
sql = "SELECT PROGRAMME,LOT_STYLE,ART FROM FABRICISSUE";
OracleCommand objCommand = new OracleCommand(sql);
OracleDataAdapter objDataAdapter = new OracleDataAdapter(objCommand);
using (OracleConnection strConn = GetConnection())
{
try
{
objCommand.Connection = strConn;
strConn.Open();
objDataAdapter.Fill(dt);
}
catch (Exception ex)
{
throw new Exception("Error : " + ex.Message);
}
finally
{
strConn.Close();
}
}
return dt;
}
现在的问题是gridview中的其他文本框正在获取数据。但下拉列表未与数据库数据绑定。SelectedValue
属性给出错误,如:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'PROGRAMME'.