Reputation: 2282
I have a situation that needs to assign a LINQ result
to a Button.Tag
property.
and when that button clicks, iterate throughout that LINQ result
placed in the Button.Tag
HINT : LINQ result is type of List<anonymousType>
. for some reason, i don't what to return List<KnownType>
any idea?
EDIT : As you all suggested, i reconsider problem and decided to create a specific class type and put DataTableRowId
in the class instead of whole DataTableRow
thing.
therefore anonymous Type Like new {Class1=c1, Class2=c2, DataTableRow3=dr3}
changed to
class of type:
public class CustomClass
{
public Class1 c1 { get; set; }
public Class c2 { get; set; }
public int DataTableRow3Id dr3 { get; set; }
}
Upvotes: 0
Views: 600
Reputation: 148180
You can not access anonymous types this way, You can make a custom class and create the result of linq to that custom type. Assign this object to tag and later type cast it back to your custom type.
Upvotes: 1