I am using C # asp.net4.
I have a method for filling the repeater with anonymous types (fields: name, category), inside the repeater I also placed a label:
var parentCategories = from c in context.CmsCategories where c.CategoryNodeLevel == 1 select new { c.Title, c.CategoryId }; uxRepeter.DataSource = parentCategories; uxRepeter.DataBind();
I need to change the text properties for each label inside my repeater on an Event Repeater ItemDataBound
protected void uxRepeter_ItemDataBound(object sender, RepeaterItemEventArgs e) { HyperLink link = (HyperLink)e.Item.FindControl("uxLabel"); uxLabel.Text =
Therefore, I need to set the properties for Label.Text using e.Item (or the best way, if any).
My problem: I cannot execute CAST e.Item (anonymous type header name) and set it as a text expression for my label.
I understand that an anonymous type can only be applied to an object type, but in my case, my anonymous type has Title and CategoryId fields.
My question is:
How to dump and retrieve a field with interest? Thanks for your time on this?
EDIT: SOME ERRORS RECEIVED:
Unable to cast object of type '<>f__AnonymousType0`2[System.String,System.Int32]' to type 'System.String'.
source share