开发者

How to convert binding value type into another in aspx?

I have this code:

<asp:CheckBox ID="CheckBoxAppStatus" r开发者_Go百科unat="server" Text="Done" Checked='<%# Bind("Status") %>'/>  

The problem is that Bind("Status") returns string (True/False), don't know why though it was defined as Boolean in the entity model.

Is there a way to convert Bind("Status") into Boolean value and still using Bind (I need to edit this value not just show it and I think using Bind is the right way to do it automatically instead of doing it by C# code).


I had once the same problem in ASP.Net, but using ADO.Net. I had to map a column that stored Y/N to a checkbox, and the solution was to simply convert the char(1) column to a bit using cast((case when YesNoColumn = 'Y' then 1 else 0 end) as bit) in the select statement, and the binding worked correctly. This, however, requires that the insert and update statements be also modified accordingly. I am not sure how this can be done in Entity Framework though.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜