G
Guest
My ASP.Net 2.0 application uses a GridView control containing a template
consisting of a checkbox and a Text property that I use to store a value to
pass to a SQL statement in the OnCheckChanged event, whose code is as follows:
If sender.checked = True Then
insVal = "'" & Me.Calendar1.SelectedDate.ToShortDateString & "'"
Else
insVal = "Null"
End If
'Get TaskID
TaskID = sender.text
sql = "update tblTask set DateDone = " & insVal & _
" where TaskID = " & TaskID
Try
dbConn.Open()
'Update database
dCmd = New SqlCommand(sql, dbConn)
RowsAffected = dCmd.ExecuteNonQuery
Catch ex As Exception
'...
Finally
If Not IsNothing(dbConn) Then
dbConn.Close()
End If
End Try
Me.gridDoList.DataBind()
This works fine if only a single row's checkbox has been checked. But if
the user changes the checked/unchecked status of more than one, only the
first one is processed. I know that I could turn on AutoPostBack causing
each click on a checkbox to immediately post back to the server, but that is
slower and causes an unpleasant "jump" in the screen position that I wish to
avoid.
Is there a way to have the server process all the changed checkboxes on a
single postback?
consisting of a checkbox and a Text property that I use to store a value to
pass to a SQL statement in the OnCheckChanged event, whose code is as follows:
If sender.checked = True Then
insVal = "'" & Me.Calendar1.SelectedDate.ToShortDateString & "'"
Else
insVal = "Null"
End If
'Get TaskID
TaskID = sender.text
sql = "update tblTask set DateDone = " & insVal & _
" where TaskID = " & TaskID
Try
dbConn.Open()
'Update database
dCmd = New SqlCommand(sql, dbConn)
RowsAffected = dCmd.ExecuteNonQuery
Catch ex As Exception
'...
Finally
If Not IsNothing(dbConn) Then
dbConn.Close()
End If
End Try
Me.gridDoList.DataBind()
This works fine if only a single row's checkbox has been checked. But if
the user changes the checked/unchecked status of more than one, only the
first one is processed. I know that I could turn on AutoPostBack causing
each click on a checkbox to immediately post back to the server, but that is
slower and causes an unpleasant "jump" in the screen position that I wish to
avoid.
Is there a way to have the server process all the changed checkboxes on a
single postback?