473,889 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CompositeDataBo undControl doesn't retreive it's state information.

I have a control derived from ComposeteDataBo undControl. Control doesn't
retreive it's state information. I am going to frick out! What should I do
more?
I added two codes. One is for Default.aspx to Test the control
"SampleDataBoun d". When I click to the "Refresh" button here, the data
displayed in the SampleDataBound control become lost.

----------------------------------------

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<script runat="server" type="text/C#">
protected override void OnLoad(EventArg s e)

{

base.OnLoad(e);

if (!Page.IsPostBa ck)

{

System.Collecti ons.Generic.Lis t<stringlist = new
System.Collecti ons.Generic.Lis t<string>();

list.Add("UMUT" );

list.Add("Mehme t");

list.Add("Hasan ");

this.d.DataSour ce = list;

this.d.DataBind ();

}

}

</script>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>Untitl ed Page</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<Test:SampleDat aBound runat="server" ID="d" EnableViewState ="true" />

</div>

<asp:Button runat="server" ID="btn" Text="Refresh" />

</form>

</body>

</html>

---------------------------------------

public class SampleDataBound : CompositeDataBo undControl, INamingContaine r

{

private Table table;

protected override int
CreateChildCont rols(System.Col lections.IEnume rable dataSource, bool
dataBinding)

{

System.Collecti ons.IEnumerator e = dataSource.GetE numerator();

table = new Table();

this.Controls.A dd(table);

TableRow row = null;

TableCell cell = null;

int count = 0;

while (e.MoveNext())

{

row = new TableRow();

cell = new TableCell();

if (dataBinding)

{

cell.Text = e.Current.ToStr ing();

}

row.Cells.Add(c ell);

table.Rows.Add( row);

count++;

}

return count;

}

}


Jul 5 '06 #1
2 1370
Hi,

you have lines

row = new TableRow();
cell = new TableCell();
if (dataBinding)
{
cell.Text = e.Current.ToStr ing();
}
row.Cells.Add(c ell);
table.Rows.Add( row);

put them in different order

row = new TableRow();
table.Rows.Add( row);
cell = new TableCell();
row.Cells.Add(c ell);

if (dataBinding)
{
cell.Text = e.Current.ToStr ing();
}

e.g do databinding after cell is added to the Rows and so on.

Reason is that a ontrol like TableCell starts its lifecycle when it's added
to the Controls collection (even though here it's to Cells, but that's
basically just abstraction) and part of this lifecycle is to start tracking
state.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

"Umut Tezduyar" <ut*******@gmai l.comwrote in message
news:OG******** *****@TK2MSFTNG P04.phx.gbl...
>I have a control derived from ComposeteDataBo undControl. Control doesn't
retreive it's state information. I am going to frick out! What should I do
more?
I added two codes. One is for Default.aspx to Test the control
"SampleDataBoun d". When I click to the "Refresh" button here, the data
displayed in the SampleDataBound control become lost.

----------------------------------------

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<script runat="server" type="text/C#">
protected override void OnLoad(EventArg s e)

{

base.OnLoad(e);

if (!Page.IsPostBa ck)

{

System.Collecti ons.Generic.Lis t<stringlist = new
System.Collecti ons.Generic.Lis t<string>();

list.Add("UMUT" );

list.Add("Mehme t");

list.Add("Hasan ");

this.d.DataSour ce = list;

this.d.DataBind ();

}

}

</script>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>Untitl ed Page</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<Test:SampleDat aBound runat="server" ID="d" EnableViewState ="true" />

</div>

<asp:Button runat="server" ID="btn" Text="Refresh" />

</form>

</body>

</html>

---------------------------------------

public class SampleDataBound : CompositeDataBo undControl, INamingContaine r

{

private Table table;

protected override int
CreateChildCont rols(System.Col lections.IEnume rable dataSource, bool
dataBinding)

{

System.Collecti ons.IEnumerator e = dataSource.GetE numerator();

table = new Table();

this.Controls.A dd(table);

TableRow row = null;

TableCell cell = null;

int count = 0;

while (e.MoveNext())

{

row = new TableRow();

cell = new TableCell();

if (dataBinding)

{

cell.Text = e.Current.ToStr ing();

}

row.Cells.Add(c ell);

table.Rows.Add( row);

count++;

}

return count;

}

}


Jul 5 '06 #2
God Bless you Teemu Keiski. I can't explain how I am happy now.

"Teemu Keiski" <jo****@aspalli ance.comwrote in message
news:ec******** ******@TK2MSFTN GP02.phx.gbl...
Hi,

you have lines

row = new TableRow();
cell = new TableCell();
if (dataBinding)
{
cell.Text = e.Current.ToStr ing();
}
row.Cells.Add(c ell);
table.Rows.Add( row);

put them in different order

row = new TableRow();
table.Rows.Add( row);
cell = new TableCell();
row.Cells.Add(c ell);

if (dataBinding)
{
cell.Text = e.Current.ToStr ing();
}

e.g do databinding after cell is added to the Rows and so on.

Reason is that a ontrol like TableCell starts its lifecycle when it's
added to the Controls collection (even though here it's to Cells, but
that's basically just abstraction) and part of this lifecycle is to start
tracking state.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

"Umut Tezduyar" <ut*******@gmai l.comwrote in message
news:OG******** *****@TK2MSFTNG P04.phx.gbl...
>>I have a control derived from ComposeteDataBo undControl. Control doesn't
retreive it's state information. I am going to frick out! What should I
do
more?
I added two codes. One is for Default.aspx to Test the control
"SampleDataBou nd". When I click to the "Refresh" button here, the data
displayed in the SampleDataBound control become lost.

----------------------------------------

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">

<script runat="server" type="text/C#">
protected override void OnLoad(EventArg s e)

{

base.OnLoad(e) ;

if (!Page.IsPostBa ck)

{

System.Collect ions.Generic.Li st<stringlist = new
System.Collect ions.Generic.Li st<string>();

list.Add("UMUT ");

list.Add("Mehm et");

list.Add("Hasa n");

this.d.DataSou rce = list;

this.d.DataBin d();

}

}

</script>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>Untitle d Page</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<Test:SampleDa taBound runat="server" ID="d" EnableViewState ="true" />

</div>

<asp:Button runat="server" ID="btn" Text="Refresh" />

</form>

</body>

</html>

---------------------------------------

public class SampleDataBound : CompositeDataBo undControl,
INamingContain er

{

private Table table;

protected override int
CreateChildCon trols(System.Co llections.IEnum erable dataSource, bool
dataBinding)

{

System.Collecti ons.IEnumerator e = dataSource.GetE numerator();

table = new Table();

this.Controls.A dd(table);

TableRow row = null;

TableCell cell = null;

int count = 0;

while (e.MoveNext())

{

row = new TableRow();

cell = new TableCell();

if (dataBinding)

{

cell.Text = e.Current.ToStr ing();

}

row.Cells.Add(c ell);

table.Rows.Add( row);

count++;

}

return count;

}

}



Jul 6 '06 #3

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

Similar topics

0
1569
by: Lee | last post by:
Hello, This is a genral enquiry before I send out a more detailed request. I am unable to retreive image files from a mysql database using IE 5.2 on the mac OS X platform. I have built a database driven website that stores images as blob files. I specify the mime types and limit the file sizes to 15k. I can retreive the images using Windows, and Mac OS 9, but explorer
3
2414
by: Not4u | last post by:
I would like to know which products are my best sells by sellers, but i would like to retreive this info by product id, seller id and the total amount of sells for this product. My Sells table is : Seller_id Product_id Total date_s 1 2 10 20/05/04 2 4 15 12/05/04 3 5 22 06/06/04 1 5 18 07/06/04
2
6061
by: Robert V. Hanson | last post by:
If you have per user information that you want to store in session and the setting in web.config is set to cookieless=false so you are intending on using cookies, the user's browser is set to not accept cookies, what can you do as alternative for storing that data? What is the tradeoff if you just set the cookieless=true? I am just trying to determine a set of best practices for this on my project.
2
783
by: Brad | last post by:
I have an intranet app that has just started sporadically getting the following error "The viewstate is invalid for this page and might be corrupted." By sproadic I mean 3-4 times during the past two days out of 100's of hits. The error just started yesterday and this app has been running for quite some time without this error and has not been updated just before or after the error started. Reseaching this error I've checked the...
1
10140
by: Sudhakara.T.P. | last post by:
Hi, I have an application in VB.NET windows application, wherein the administrator has the option to change the authentication mode ie., whether the application should work as a normal database authentication or the windows based authentication mode. If the administrator sets the application authentication mode to windows based, then the application has to verify the windows logged in username and password and then allow the user to use...
4
2029
by: robinsand | last post by:
Header File: car.h #if !defined CAR_H #define CAR_H enum TCarType { ctEconomy = 1, ctCompact, ctStandard, ctFullSize, ctMiniVan, ctSUV }; class Car { public: Car();
0
1187
by: Umut Tezduyar | last post by:
I have a control derived from ComposeteDataBoundControl. Control doesn't retreive it's state information. I am going to frick out! What should I do more? I added two codes. One is for Default.aspx to Test the control "SampleDataBound". When I click to the "Refresh" button here, the data displayed in the SampleDataBound control become lost. ---------------------------------------- <%@ Page Language="C#" %>
1
2104
by: Griff | last post by:
Hi I want to create an n-tier custom server control. The idea is that the control will determine which "view" will be used. By this I mean User A may want the data displayed as a tree-view, User B as a datagrid etc, etc. So, I can envisage that in some circumstances it is using a data bound control and in others a non-data bound control - who knows. In which case,
28
2140
by: ensemble | last post by:
I'm trying to utilized a more object-oriented approach to managing window events in javascript. Thus, I am creating a "controller" object to handle events and interact with the server. However, I apparently don't fully understand what "this" refers to. In the code below I was expecting that when the button was clicked (handleDeleteButtonClicked function) that "this" would be pointing at a ViewController object. Instead it was the Button...
0
9962
marktang
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...
0
9810
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,...
0
10791
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 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...
0
10442
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 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...
0
9609
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, 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...
0
7150
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5829
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...
0
6029
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3256
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.