Viewstate!

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
 
J

JIMCO Software

Adam said:
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?


That's not Viewstate. It's the IPostBackDataHandler interface. If you want
other data, you need to override LoadPostData (not entirely sure you can,
but that's the function that's responsible for redoing the form in this
case) or databind again.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top