开发者

Compute aspx attribute value at runtime

开发者 https://www.devze.com 2023-03-31 14:04 出处:网络
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开发

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

精彩评论

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