Today, I saw a similar article, realizing the CHECKBOX client implementation in the DataGrid, so I want to implement the server-side code, so I started trying!
The ASPX code is as follows
Note this part of the code:
Write a public function in the background code, pay attention to relevant parameters.
Extract the presentation data part, note not ispostback
Private Sub Page_Load (Byvale AS System.Object, Byval E AS System.Eventargs) Handles MyBase.Load
User code 'page initialization placed here If Not IsPostBack Then Dim cnn As New SqlConnection ( "data source = localhost; initial catalog = model; integrated security = sspi") Dim cmd As New SqlCommand ( "select * from sysusers", CNN) DIM Adapter As New SqldataAdapter (CMD) DIM DST AS New DataSet
Try Adapter.Fill (DST) DGDscoreshow.DataSource = DST.TABLES (0) .defaultview DGDSCORESHOW.DATABIND () Catch EX AS Exception Response.write (ex. measureage) End Try End If End Sub Custom Function Section
Public Sub checkchange (ByVal sender As System.Object, ByVal e As System.EventArgs) Dim item As DataGridItem For Each item In dgdScoreshow.Items Dim chk As CheckBox chk = item.FindControl ( "chkchoose") If CType (sender, CheckBox) .Checked the chk.checked = true else chk.checked = false end if Next end SUB
The server-side code control can be implemented in the server-side code to control the full choice of Checkbox in DataGrid.