In some cases, checkboxfield will need to terminate the position of a non-Blin value, for example, the ending bit value is 0 or 1; however, if the checkboxfield value of the parameter is 0 or 1 (non-Blin value), a dynamic sequence is generated. The general solution is to use templatefield for processing, but this article uses another method to modify the checkboxfield class, so that checkboxfield can distinguish between the 0 or 1 percentile values.
The procedure is as follows:
1. Add a class and upload it to the checkboxfield name tbcheckboxfield.
2. Override the ondatabindfield method to process the struct value.
3. In the *. aspx upload case, use tbcheckboxfield to replace checkboxfield.
<PC3: tbcheckboxfield datafield = "sex" headertext = "sex"/>
The program history of bcheckboxfield is as follows:
1 Imports system. componentmodel
2 imports system. Web
3 Imports system. Web. UI
4 Imports system. Web. UI. webcontrols
5
6 <_
7 description (" ")_
8> _
9 public class tbcheckboxfield
10 inherits checkboxfield
11
12''' <summary>
13 ''' end the vertex value to the vertex of the tbcheckboxfield object.
14''' </Summary>
15 ''' <Param name = "sender"> indicates the control role. </Param>
16 ''' <Param name = "E"> event reference. </Param>
17 protected overrides sub ondatabindfield (byval sender as object, byval e as eventargs)
18 dim ocontrol as control = directcast (sender, control)
19 dim onamingcontainer as control = ocontrol. namingcontainer
20 dim ofieldvalue as object = me. getvalue (onamingcontainer)
21
22 if not typeof ocontrol is checkbox then
23 throw new httpexception ("forbidden control operator non-core operator ")
24 end if
25
26 if isdbnull (ofieldvalue) then
27 directcast (ocontrol, checkbox). Checked = false
28 elseif typeof ofieldvalue is Boolean then
29 directcast (ocontrol, checkbox). Checked = cbool (ofieldvalue)
30 else
31 try
32 directcast (ocontrol, checkbox). Checked = cbool (ofieldvalue. tostring)
33 catch exception as formatexception
34 throw new httpexception ("the value cannot be regarded as a Boolean value", exception)
35 end try
36 end if
37 directcast (ocontrol, checkbox). Text = me. Text
38 end sub
39
40 end class