开发者

Databinding does not contain a property with the name

I know this question has been asked numerous times before, but I feel the way I am going about this is a little unique so would like to get some more experienced feedback as this is baffling me a little bit.

As it stands, I have a basic ecom system, where clients can add there own products. When they edit the item, I have a section of dropdowns and would like the data to relate to the selections they made initially (to avoid them cocking up mass amounts of data!).

Currently 2 of the 3 drop downs work fine but the 3rd consists on data linked between 2 tables. This is where my problems are starting to occur. I can write to the table fine, but when I call data to the drop down I get the age old "does not contain a property with the name 'SubCatID'" error!!!

Here is the drop down code:

<li ID="ERow6" runat="server" visible="false"><label>Subcategory</label><span>
 <asp:DropDownList ID="DDL_Subcategory" runat="server" DataSource='<%#Eval("GetSubcat")%>' DataValueField="id" DataTextField="txt" SelectedValue='<%#Bind("SubCatID")%>'></asp:DropDownList></span></li>

and here is the c# I am calling:

GetSubcat = x.DT_Category.DT_SubCategories.Select(i => new { txt = i.SubcatName, id = i.SubCatID}),

How is it that the ID cannot be found????

Thanks in adv开发者_StackOverflowance.


Looking at this line:

i => new { txt = i.SubcatName, id = i.SubCatID}),

You are creating a new anonymous object with properties txt and id and it looks like you're binding to SubCatID, correct me if I'm wrong.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜