473,395 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Viewstate!

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("a smt_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
Nov 19 '05 #1
2 1104
Adam Knight wrote:
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


Nov 19 '05 #2
Solved problem..
Logic Error. Code was fine..

Thanks.

"Adam Knight" <ad**@pertrain.com.au> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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("a smt_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

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
10
by: neo | last post by:
hi, I am studying ASP.NET and have few questions - 1) The session ID and values of controls is stored in VIEWSTATE variable. So now when we put EnableViewState="false" in Page directive and...
1
by: Simon | last post by:
Hi everyone, I have a quick question that I hope someone can help me with: I've made a user control that contains a text box and some validation functionality. This control has a few extra...
7
by: et | last post by:
I'm not sure I understand the use of the ViewState. Do I understand correctly that values of controls are automatically held in a hidden control called ViewState? If so, then why can't we get...
3
by: RCS | last post by:
I have an app that I have different "sections" that I want to switch back and forth from, all while having the server maintain viewstate for each page. In other words, when I am on Page1.aspx and...
9
by: Mark Broadbent | last post by:
Been a while since I've touched asp.net but one thing that always seems to fustrate me is the loss of state on variable declarations. Is there anyway (i.e. assigning an attribute etc) to instruct...
6
by: hitendra15 | last post by:
Hi I have created web user control which has Repeater control and Linkbutton in ItemTemplate of repeater control, following is the code for this control On first load it runs fine but when...
6
by: paul.hester | last post by:
Hi all, Does anyone know why the ViewState would be empty? When I'm receiving a postback, I can access a posted value using controlName.Value but not ViewState. I have EnableViewState set...
12
by: Nick C | last post by:
Hi How can i reduce the viewstate for my asp.net application. It is getting very large now. What is a good solution? thanks N
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.