A
Adam Knight
Hi all,
I am databind a checkbox in a datagrid to a db value.
My issue is, when i change the data being displayed via a dropdownlist,
any previously checkbox selections are maintained in the grid though the
data has changed (i would image a viewstate issue).
Instead i am after an accurate representation from the db.
Any thoughts on this?
Cheers,
Adam
Code Below:
Sub dgEmps_OnItemDataBound(ByVal Sender As Object, ByVal e As
DataGridItemEventArgs)
'variable declaration
Dim lbtnDelete As LinkButton
Dim chkMailSubscriber As Checkbox
'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 mailgroup info has been requested
If(ddlMailGroups.SelectedIndex > 0) Then
chkMailSubscriber =
CType(e.Item.Cells(0).Controls(1),CheckBox)
'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
chkMailSubscriber.Checked = True
AddHandler chkMailSubscriber.CheckedChanged, AddressOf
UpdateMailSubScribers
chkMailSubscriber.EnableViewState = False
Else
chkMailSubscriber.Checked = False
AddHandler chkMailSubscriber.CheckedChanged, AddressOf
UpdateMailSubScribers
chkMailSubscriber.EnableViewState = False
End If
End If
End If
End Sub
I am databind a checkbox in a datagrid to a db value.
My issue is, when i change the data being displayed via a dropdownlist,
any previously checkbox selections are maintained in the grid though the
data has changed (i would image a viewstate issue).
Instead i am after an accurate representation from the db.
Any thoughts on this?
Cheers,
Adam
Code Below:
Sub dgEmps_OnItemDataBound(ByVal Sender As Object, ByVal e As
DataGridItemEventArgs)
'variable declaration
Dim lbtnDelete As LinkButton
Dim chkMailSubscriber As Checkbox
'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 mailgroup info has been requested
If(ddlMailGroups.SelectedIndex > 0) Then
chkMailSubscriber =
CType(e.Item.Cells(0).Controls(1),CheckBox)
'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
chkMailSubscriber.Checked = True
AddHandler chkMailSubscriber.CheckedChanged, AddressOf
UpdateMailSubScribers
chkMailSubscriber.EnableViewState = False
Else
chkMailSubscriber.Checked = False
AddHandler chkMailSubscriber.CheckedChanged, AddressOf
UpdateMailSubScribers
chkMailSubscriber.EnableViewState = False
End If
End If
End If
End Sub