473,386 Members | 1,821 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,386 software developers and data experts.

DataGrid event fireing


Hi,

How does events fire in a datagrid.

I know about the problem if turning the viewstate off the events wil
not fire properly even if I rebind the control in every postback. S
then I started to think how does .Net do it if I turn the viewstat
on.

If you use the Request.Form then you can get all the controls tha
existed in the previous postback and the hidden field with viewstate.
suspect that the event is embedded in this viewstate or something tha
will create events to fire in the codebehind.

I would appreciate some help in figuring out how this machinery works
Then maybe it is possible to handle this downside with datagrid.

Yours sincerely
Andl

andl
-----------------------------------------------------------------------
Posted via http://www.mcse.m
-----------------------------------------------------------------------
View this thread: http://www.mcse.ms/message395193.htm

Nov 18 '05 #1
2 2368
datagrid events fire off when they are hooked to their specific events.
in the initializecomponent section you will see this
datagrid.itemdatabound += new some stuff (itemdataboundeventhandler)

this tells the machinery that when ever the itemdatabound fires off in the
datagrid, call the code in itemdataboundeventhandler found in the
codebehind. when you turn off viewstate, it doesn't remember this line, so
the events don't call any code. so before you bind you have to manually
rehook the events using

datagrid.itemdatabound += new some stuff (itemdataboundeventhandler)

makes sense?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"andla" <an**********@mail.mcse.ms> wrote in message
news:an**********@mail.mcse.ms...

Hi,

How does events fire in a datagrid.

I know about the problem if turning the viewstate off the events will
not fire properly even if I rebind the control in every postback. So
then I started to think how does .Net do it if I turn the viewstate
on.

If you use the Request.Form then you can get all the controls that
existed in the previous postback and the hidden field with viewstate. I
suspect that the event is embedded in this viewstate or something that
will create events to fire in the codebehind.

I would appreciate some help in figuring out how this machinery works.
Then maybe it is possible to handle this downside with datagrid.

Yours sincerely
Andla
andla
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message395193.html

Nov 18 '05 #2
Hi Andla,
The viewstate is maintained automatically across postbacks by the
ASP.NET Framework.
The viewstate is read when a page is posted to the server.The viewstate is
restored just before the page is
sent back to the browser.
The viewstate is saved in the state bag using hidden
fields that contain state encoded in a string variable.
State Bag is a data structure containing attribute/value pairs,stored as
string associated with objects.
If you want to preserve the values which are not associated with
any particular control
and if you wish to preserve those values across postbacks you can store
these values is the Pages's state bag.
For example when an Itemcommand event happens in your
datagrid,the browser handles the client side event
to post back to the server which send an event message to the server as
well.Viewstate information is used in handling events.
The server determines if the Itemcommand event has an event
handler associated with it and if there is,the event handler code
is executed at the server.The event message is send to the server by HTTP
POST.ASP.NET automatically do all this for you.What
you have to do is create your event handlers.
Since there is data posted back and forth with every
post,if there is large amount of data you need to handle,
in your datagrid with the EnnableViewState is true ,the page loading can be
very slow and the page size can be too big.
You could use paging in scenarios like this if needed.
However you can disable view state of the datagrid and handle
events using certain guidelines.
Here is an article on this :

http://authors.aspalliance.com/JimRo...agridDiet.aspx

Hope this helps.

Marshal Antony
..NET Developer
http://www.dotnetmarshal.com
"andla" <an**********@mail.mcse.ms> wrote in message
news:an**********@mail.mcse.ms...

Hi,

How does events fire in a datagrid.

I know about the problem if turning the viewstate off the events will
not fire properly even if I rebind the control in every postback. So
then I started to think how does .Net do it if I turn the viewstate
on.

If you use the Request.Form then you can get all the controls that
existed in the previous postback and the hidden field with viewstate. I
suspect that the event is embedded in this viewstate or something that
will create events to fire in the codebehind.

I would appreciate some help in figuring out how this machinery works.
Then maybe it is possible to handle this downside with datagrid.

Yours sincerely
Andla
andla
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message395193.html

Nov 18 '05 #3

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

Similar topics

6
by: Mark Nijhof | last post by:
Hi, A quicke summarize: I made a windows form that can set up a socket connection. It also has events that fire when data arives. Now I am using this form in a hidden way inside other code (was...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
4
by: Ryan Ternier | last post by:
I have a button event: Public Sub SwitchItem(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim btnTest As New Button Dim astrTest As String() btnTest = CType(sender, Button)...
3
by: Jay | last post by:
In Page_Load I try to use the this.Menu1.SelectedValue on postBack situations for the purpose of building the page. But it appears that the selected value does not show up until the...
3
by: William E Voorhees | last post by:
I have code (using the leave event) in a textbox which prevents the user from leaving the box if it is blank. I would like the user to be able to click on the button of the form and close that...
8
by: moondaddy | last post by:
I'm working in WPF and c# and am adding an event handler to an object like this: this.tgt.SizeChanged += new SizeChangedEventHandler(OnTargetSizeChanged); Later I kill the instance of...
2
by: Rasmus Kromann-Larsen | last post by:
Hey, Messing with JavaScript on a webpage, I ran into a small problem. Wanting to have a table cell select it's contained radiobutton in a rather non-specific way, I wrote the following...
1
by: Shrek | last post by:
I create a <DIV> and <TABLE> from javascript, which drops down when a user clicks a button. The div has a onMouseout event that is intended to hide the div when the user moved the mouse away from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.