Previously, checkboxlist was used in the project. To obtain the checkbox information on the server after clicking a checkbox, such as index, it seems that it is not supported. After searching for some methods on the internet, the following describes the solutions for loadpostdata and raisepostdatachangedevent of the overloaded checkboxlist.
Steps:
1. Rewrite loadpostdata and raisepostdatachangedevent of checkboxlist (for details, see the followingCodeNote)
2. From bulletedlisteventargs in your own event, you can get the index of the current click.
1
2 Public Class Mycheckboxlist: checkboxlist
3 {
4 Private Int _ Currentitemindex;
5
6 Protected Override Bool Loadpostdata ( String Postdatakey, system. Collections. Specialized. namevaluecollection postcollection)
7 {
8
9 Bool Retval = Base . Loadpostdata (postdatakey, postcollection );
10
11 If (Retval)
12 {
13 // This function is transferred to every checkbox, that is, the number of calls to this function is the number of subcheckboxes it owns.
14 // The value is obtained only when the return value is true,
15 // Otherwise, the index is always the largest.
16 This . _ Currentitemindex = Int . Parse (postdatakey. substring ( This . Uniqueid. Length + 1 ), Cultureinfo. invariantculture );
17 }
18
19 Return Retval;
20 }
21
22 Protected Override Void Raisepostdatachangedevent ()
23 {
24 If ( This . Autopostback && ! This . Page. ispostbackeventcontrolregistered)
25 {
26 This . Page. autopostbackcontrol = This ;
27 If ( This . Causesvalidation)
28 {
29 This . Page. Validate ( This . Validationgroup );
30 }
31 }
32 This . Onselectedindexchanged ( New Bulletedlisteventargs ( This . _ Currentitemindex ));
33 }
34 }
35