Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / October 2004

Tip: Looking for answers? Try searching our database.

Datagrid lose Items in Postback

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Amir - 21 Oct 2004 11:55 GMT
Hi all
I have only a Datagrid and a submit button on a form.
I use 2 template columns and some bounded columns in my grid too.

I just want to process Datagrid's items in a for loop in the event handler
of Button click.
My loop look like this:
for(int i=0;i<dg.Items.Count;i++)
{
....
}

but "dg.Items.Count" after postback is ZERO when I debug the code.
It's not zero in Page_load method after postback.
irene - 27 Oct 2004 20:52 GMT
On your datagrid property, Set EnableViewState="true" should fix that problem.

Irene

> Hi all
> I have only a Datagrid and a submit button on a form.
[quoted text clipped - 10 lines]
> but "dg.Items.Count" after postback is ZERO when I debug the code.
> It's not zero in Page_load method after postback.
Amir - 28 Oct 2004 06:43 GMT
It was
I think it's because of .NET Framework SP1.

> On your datagrid property, Set EnableViewState="true" should fix that problem.
>
[quoted text clipped - 14 lines]
> > but "dg.Items.Count" after postback is ZERO when I debug the code.
> > It's not zero in Page_load method after postback.
irene xie - 28 Oct 2004 16:20 GMT
What happen if you take off the "if not ispostback " from the Page_Load?

Irene
Amir - 29 Oct 2004 06:09 GMT
execute the code in the page_load.
Irene, It find also the ItemCommand's event handler. but my code can not
count the Datagrid's items. because DG.Items.Count is ZERO in the event
handler.

It's very amazing that it's not ZERO in page_load when I debug my code.

> What happen if you take off the "if not ispostback " from the Page_Load?
>
> Irene

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.