Data Gridden server-side server-side server-e-elevable server-e-chooses in DataGrid!

xiaoxiao2021-03-06  120

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

< asp: TemplateColumn>

Note this part of the code: Add a checkbox, so you can implement the Header section Show a check box, but also pay attention to AutoPostBack = true, otherwise nothing is not implemented.

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.

转载请注明原文地址:https://www.9cbs.com/read-125748.html

New Post(0)