开发者

Compute aspx attribute value at runtime

I have a DataSet that contains columns that related to enums in my application. I therefore extended the BoundField control to create a new control EnumBoundField. This will take the integer value开发者_如何学JAVA held in the DataSet and display the description of the enum.

However I would like to add a property to the new control call EnumType and this would be of type System.Type.

e.g.

public Type EnumType{ get; set; }

In my aspx where I define the GridView I would like to use my control like:

<cust:EnumBoundField HeaderText="Status" DataField="statusField" EnumType="<%= typeof(SystemStatus)%>" />

However the above results in the string '<%= typeof(SystemStatus)%>' being passed to my control. Do you know if it is possible to have the the type of Enum passed to the control at run time?

I want to make this control as reusable as possible so that I can reuse it on multiple columns by just passing in a different enum type.


the <%= %> syntax does not work as a databinding expression try <%# %>

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜