我有 2 节课:
public class clsShipper
{
public string ShipperName { get; set; }
}
和
public class clsJobInfo
{
public long JobID { get; set; }
public clsShipper oShipper = new clsShipper();
}
我的 GridView 如下
<asp:GridView ID="dgvJobCostList" runat="server" CellPadding="4" ForeColor="#333333" style="font-family:Verdana;font-size:10px;" AutoGenerateColumns="False" OnSelectedIndexChanged="dgvJobCostList_SelectedIndexChanged">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkRowCheck" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ID">
<ItemTemplate>
<asp:Label ID="lblJobID" runat="server" Text='<%# Bind("JobID") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Shipper">
<ItemTemplate>
<asp:Label ID="lblShipperName" runat="server" Text='<%# Bind("ShipperName") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
我正在尝试通过 JobInfo 类对象绑定 Shipper 类的 ShipperName 属性。我在下面试过
protected void btnSearch_Click(object sender, EventArgs e)
{
if (oOutputJobInfo.Length < 1)
{
lblMessage.Text = "Error : No Data Found";
lblMessage.Visible = true;
return;
}
else
{
dgvJobCostList.DataSource = oOutputJobInfo;
dgvJobCostList.DataBind();
dgvJobCostList.Visible = true;
}
}
但给出以下错误
DataBinding:“Nucleus.BOL.clsJobInfo”不包含名为“ShipperName”的属性。