I've found what seems to be a nasty bug in the DataGrid and Repeater
classes. If CreateChildCont rols gets called before LoadViewState,
ViewState fails to map and you end up with nothing on a Postback.
Please try the following test, and let me know if you can reproduce
this:
- Create a custom DataGrid or Repeater class that does nothing but
derive from one of the above and gives a place to put breakpoints in
overriden handlers
- Create a simple test case on a WebForm. I use template columns, but
BoundColumns might work as well.
- Create something in your DataGrid/Repeater that posts back, like a
LinkButton in a HeaderTemplate.
- Only DataBind if it's not a PostBack
- Put an EnsureChildCont rols at the beginning of OnInit in your custom
DataGrid/Repeater
When I click on the LinkButton, I get no output at all. Put
breakpoints in OnInit, LoadViewState, and CreateChildCont rols of your
custom class. If CreateChildCont rols gets called before LoadViewState,
nothing maps and there's no output. Now, if you take
EnsureChildCont rols out of OnInit, and your test is simple, you'll see
LoadViewState happen before CreateChildCont rols and everything will
work wonderfully.
Why is that? That's exactly opposite from everything I've learned so
far concerning server controls. Usually, the earlier you re-create all
your controls the better for mapping events, ViewState, etc. Why are
these framework controls different? I can't avoid having my controls
created early in my big application because I usually put
EnsureChildCont rols in all my Properties, etc, like I thought was good
practice. Are DataGrids and Repeaters doomed to fail with these
practices?
I've considered finding a workaround. I even considered calling
LoadViewState at the beginning of CreateChildCont rols on a PostBack,
but I haven't tried it yet because I don't know if it would be safe to
do it even if it's possible. Any help or input on why this is
happening or any hacks or workarounds will be very welcome. 0 1505 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jeremy Ames |
last post by:
I am trying to use a datagrid to pull information from a database. I prefer
to use latebinding to this. Well, I finally got my information to populate
the datagrid, but the information came out in a table format. Is there a way
that I can make the datagrid use list box or some other kind of grid?
Perhaps I am using the wrong components. Someone please help.
|
by: Stephen Miller |
last post by:
I am using the OnItemDataBound event of Repeater control to nest a
DataGrid within the Repeater. When I attempt to bind to the DataGrid
using the DataSource method I get the error message "Object reference
not set to an instance of an object". This error message commonly
occurs when a server control is incorrecly declared, so naturally I
have double checked this.
To test this, I moved the aspx code for the DataGrid
('myNestedDataGrid')...
|
by: SSW |
last post by:
Hi:
In aspx.cs page i had written the code below. I only have TextBox and Button
Control. LoadViewStateis Never called But when we put datagrid/DataList It
works. Can any one, please tell where i'm going wonge.
Thanks,
sswalia
----------------------------------------------------------------------------
|
by: SSW |
last post by:
Hi:
In aspx.cs page i had written the code below. I have a button control and
only create TextBox Control dynamically. LoadViewState is Never called.
But when we put datagrid/DataList it works. Can any one help me with this?
Thanks,
SSW
|
by: Rick |
last post by:
Hello all, I hope all is well with you.
I am having a seriously difficult time with this problem. Allow me to
set
up the problem.
I have a System.Web.UI.Page with the following controls (watch the
layout,
some have child controls):
| |
by: Scott Schluer |
last post by:
Hi All,
I have a functioning datagrid on "Page 1" that displays order information
for a single order (this is for an e-commerce site). It's actually a
combination of a couple datagrids to display all of the information.
I now have a need to drop this datagrid into a repeater on "Page 2". The
repeater will grab ALL orders within a given date range and output the
datagrids for each order. Remember, the Page 1 is built to display one...
|
by: News |
last post by:
Hi I need help to display and edit data in a data grid within a repeater.
The code is below:
Sub dgrdEvents_EditCommand(sender As Object, e As DataGridCommandEventArgs)
dgrdEvents.EditItemIndex = e.Item.ItemIndex
BuildList()
End Sub
|
by: Nergal |
last post by:
LoadViewState is taking a long time on a page, the bigger the dataset the
longer the wait and also it takes longer on remote server than local host.
EnableViewState is FALSE and when I examine the viewstate size for the
datagrid in trace it is ZERO.
But the view state string is very long :|
What the heck is going on here ? ViewState gurus neeeded.
|
by: JD |
last post by:
Hello Everyone,
I am trying to do a page where when the user gets to the page it will look
very similar to the following:
<table border=1>
<tr>
<td bgcolor="green" colspan="2">Main Header</td>
</tr>
<tr><td bgcolor="gray">SubHead1</td><td bgcolor="gray">Subhead2 -
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |