My DataGrid control has footer and this footer contains a custom web user
control. The control included via footer template at the desing time. I
don't create it manually.
The user control contains a DropDownList that populates data on its own Load
event as :
if (!IsPostBack)
{
...
rdr = cmd.ExecuteRead er();
MyLst.DataValue Field = "...";
MyLst.DataKeyFi eld = "...";
MyLst.DataSourc e = rdr;
MyLst.DataBind( );
rdr.Close();
conn.Close();
}
As you see, it populates items only one time.
ViewState at all levels (page, control, item and etc) is enabled.
After postbacks the the list does not lose its items if the datagrid does
not
do re-binding. But if my some commands force re-binding of the datagrid.
And after re-binding, the list becomes empty. What am I doing wrong?
Any help? 2 1279
Databinding of the grid results in databinding of the footer. Probably, it
in turn causes databinding of all controls included in the footer and
MyLst.DataBind( ) gets called.The DataSource property doesn't get restored in
postback and that's why the ddl becomes empty after databinding.
Try populating the ddl in the datagrid's ItemDataBound event when it is
raised for the footer item.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"TumurS" <sp********@mag icnet.mnwrote in message
news:%2******** *******@TK2MSFT NGP05.phx.gbl.. .
My DataGrid control has footer and this footer contains a custom web user
control. The control included via footer template at the desing time. I
don't create it manually.
The user control contains a DropDownList that populates data on its own
Load
event as :
if (!IsPostBack)
{
...
rdr = cmd.ExecuteRead er();
MyLst.DataValue Field = "...";
MyLst.DataKeyFi eld = "...";
MyLst.DataSourc e = rdr;
MyLst.DataBind( );
rdr.Close();
conn.Close();
}
As you see, it populates items only one time.
ViewState at all levels (page, control, item and etc) is enabled.
After postbacks the the list does not lose its items if the datagrid does
not
do re-binding. But if my some commands force re-binding of the datagrid.
And after re-binding, the list becomes empty. What am I doing wrong?
Any help?
Yes, thank you!
I expected something similar.
So, is there any way to avoid rebinding?
I.e. prevent the list from clearing?
The list content is constant and I don't want
to access a db every time when the datagrid
is binded. Of course, I can store its items
in page's ViewState and load back on the binding event.
But may be asp.net has simpler builtin method
to aviod rebinding?
"Eliyahu Goldin" <RE************ **************@ mMvVpPsS.orgwro te in
message news:OI******** ******@TK2MSFTN GP03.phx.gbl...
Databinding of the grid results in databinding of the footer. Probably, it
in turn causes databinding of all controls included in the footer and
MyLst.DataBind( ) gets called.The DataSource property doesn't get restored
in postback and that's why the ddl becomes empty after databinding.
Try populating the ddl in the datagrid's ItemDataBound event when it is
raised for the footer item.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"TumurS" <sp********@mag icnet.mnwrote in message
news:%2******** *******@TK2MSFT NGP05.phx.gbl.. .
>My DataGrid control has footer and this footer contains a custom web user control. The control included via footer template at the desing time. I don't create it manually. The user control contains a DropDownList that populates data on its own Load event as :
if (!IsPostBack) { ... rdr = cmd.ExecuteRead er(); MyLst.DataValue Field = "..."; MyLst.DataKeyFi eld = "..."; MyLst.DataSourc e = rdr; MyLst.DataBind( ); rdr.Close(); conn.Close(); }
As you see, it populates items only one time. ViewState at all levels (page, control, item and etc) is enabled. After postbacks the the list does not lose its items if the datagrid does not do re-binding. But if my some commands force re-binding of the datagrid. And after re-binding, the list becomes empty. What am I doing wrong? Any help? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Vit |
last post by:
Hi.
I'd like to pass as a parameter of class method reference
to ListControl (ListBox or ComboBox).
Here is my call:
public DoSomething(ListControl lc){}
It's ok with that, but lc does not have methods like
lc.BeginUpdate;
lc.EndUpdate
but ListBox and ComboBox does have such a methods.
I don't like two methods like
|
by: Bryan Ax |
last post by:
I have a page that has two copies of the same control in it. The
control is:
BorrowerControl
the two references to it in the page are
bControl1
cobControl1
|
by: Elad Volpin |
last post by:
Can someone please explain this:
I created a new webform with a PlaceHolder and a Button.
My Page_Load contains the following code:
private void Page_Load(object sender, System.EventArgs e)
{
ListControl l = null;
ListItem item = new ListItem("a", "b");
|
by: Janaka |
last post by:
Help! I have two ListBox controls on my web form. The first one gets
populated on entry with values from the DB. I then use JavaScript to copy
options from this ListBox to my second one. (I have also tried changing the
second ListBox to an HtmlSelect control) using bog standard JavaScript code
like so where "used" is the name of my <select> control:
used.options = new Option(name, typeId);
This all works fine and I can move across...
|
by: SK |
last post by:
Hello,
I have a list control, with multiselection enabled. Now
when the user selects something the first time from it,
then I can easily write out the selected items, but on
postback I cant do that, although they are selected.
I mean I can print the selected items, but I cant do it
after the postback. It behaves like there is no selected
item, but i can see that they are selected.
| |
by: Ken Varn |
last post by:
I have a problem where my DataGrid would not maintain the ViewState of my
databound rows. I finally narrowed down the problem. If my first column is
a template column, the view state for the DataGrid items is not maintained
on postback for some reason.
I basically re-created my DataGrid again just to make sure this was indeed
the problem. The ViewState was fine until I added the template column at
the beginning of the Columns list. ...
|
by: Mike Caputo |
last post by:
Does anyone know why the ListControl base class doesn't have an Items
property in Windows Forms, but does in Web Forms? This seems kind of
pointless and is really annoying when trying to write a generic procedure
for adding items to a ListControl in Windows Forms (I know I could use the
DataSource property, but I need to be able to add and remove). Anyway, I
can work around it, but I'm really curious to know why that's the case.
Thanks....
|
by: palani ganesh |
last post by:
hi all,
i m ganesh a newbie to this site........ In my program i want to insert, delete items in the listcontrol using the popmenu.....Is ther anyone to help me out????
awaiting for ur reply...
thanks in advance
with regards
ganesh
|
by: Rich Raffenetti |
last post by:
I have a form with a listview control and a textbox. When I change focus
from the listview to the textbox, the highlighted item on the listview loses
the highlight. That is not the behavior I need.
I am using VB2008 express. I see that the behavior of a similar program in
VB6 is the same.
When the controls are a listbox and a textbox, the highlighted item remains
highlighted when changing focus to the textbox. So I might guess that...
|
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: 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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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.
| |