Let the checkboxfield struct end a non-Boolean value (0 or 1) Digit

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.