A
Adam Knight
Hi all,
I have a datagrid with a checkbox in one column.
The checkbox is set to autopostback and calls a method named
UpdateMailSubscribers.
The first click on the checkbox cause the page to post but doesn't seem to
haven't any affect.
It doesn't appear to call the UpdateMailSubscribers method.
Relevant Code Below:
<asp:CheckBox AutoPostBack="true" OnCheckedChanged="UpdateMailSubscribers"
Runat="server"/>
Sub dgEmps_OnItemDataBound(ByVal Sender As Object, ByVal e As
DataGridItemEventArgs)
'variable declaration
Dim lbtnDelete As LinkButton
'ensure current data grid row is not a header or footer
If(e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <>
ListItemType.Footer AND dgEmps.EditItemIndex = -1) Then
'determine if account belongs to selected mail group
If(DsEmps.Tables(0).Rows(e.Item.ItemIndex).Item("asmt_mail_subscriber_id").GetType.ToString
<> "System.DBNull") Then
'assign checkbox id "asmt_mail_subscriber_id"; used for
deletion
CType(e.Item.Cells(0).Controls(1),CheckBox).ID =
DsEmps.Tables(0).Rows(e.Item.ItemIndex).Item("asmt_mail_subscriber_id")
CType(e.Item.Cells(0).Controls(1),CheckBox).Checked =
True
Else
'assign checkbox id "account id"; used for insertion
CType(e.Item.Cells(0).Controls(1),CheckBox).ID =
dgEmps.DataKeys(e.Item.ItemIndex)
CType(e.Item.Cells(0).Controls(1),CheckBox).Checked =
False
End If
End If
End If
End Sub
Sub UpdateMailSubScribers(ByVal sender As Object, e As System.EventArgs)
'variable declaration
Dim chkMailSubscriber As CheckBox
Dim cmdDelete As SqlCommand
Dim cmdInsert As SqlCommand
chkMailSubscriber = CType(sender,CheckBox)
'determine if an account mail subscription is being added or removed
If(chkMailSubscriber.Checked = False) Then
'delete account subscription stored procedure
'rebind datagrid to datasource
dgEmps_BindData()
Else
'insert account subscription stored procedure
'rebind datagrid to datasource
dgEmps_BindData()
End If
lblDebug.Text = "Sender:" & CType(sender,CheckBox).Checked
End Sub
I have a datagrid with a checkbox in one column.
The checkbox is set to autopostback and calls a method named
UpdateMailSubscribers.
The first click on the checkbox cause the page to post but doesn't seem to
haven't any affect.
It doesn't appear to call the UpdateMailSubscribers method.
Relevant Code Below:
<asp:CheckBox AutoPostBack="true" OnCheckedChanged="UpdateMailSubscribers"
Runat="server"/>
Sub dgEmps_OnItemDataBound(ByVal Sender As Object, ByVal e As
DataGridItemEventArgs)
'variable declaration
Dim lbtnDelete As LinkButton
'ensure current data grid row is not a header or footer
If(e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <>
ListItemType.Footer AND dgEmps.EditItemIndex = -1) Then
'determine if account belongs to selected mail group
If(DsEmps.Tables(0).Rows(e.Item.ItemIndex).Item("asmt_mail_subscriber_id").GetType.ToString
<> "System.DBNull") Then
'assign checkbox id "asmt_mail_subscriber_id"; used for
deletion
CType(e.Item.Cells(0).Controls(1),CheckBox).ID =
DsEmps.Tables(0).Rows(e.Item.ItemIndex).Item("asmt_mail_subscriber_id")
CType(e.Item.Cells(0).Controls(1),CheckBox).Checked =
True
Else
'assign checkbox id "account id"; used for insertion
CType(e.Item.Cells(0).Controls(1),CheckBox).ID =
dgEmps.DataKeys(e.Item.ItemIndex)
CType(e.Item.Cells(0).Controls(1),CheckBox).Checked =
False
End If
End If
End If
End Sub
Sub UpdateMailSubScribers(ByVal sender As Object, e As System.EventArgs)
'variable declaration
Dim chkMailSubscriber As CheckBox
Dim cmdDelete As SqlCommand
Dim cmdInsert As SqlCommand
chkMailSubscriber = CType(sender,CheckBox)
'determine if an account mail subscription is being added or removed
If(chkMailSubscriber.Checked = False) Then
'delete account subscription stored procedure
'rebind datagrid to datasource
dgEmps_BindData()
Else
'insert account subscription stored procedure
'rebind datagrid to datasource
dgEmps_BindData()
End If
lblDebug.Text = "Sender:" & CType(sender,CheckBox).Checked
End Sub