Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
|
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 23rd, 2007, 08:16 AM
Registered User
 
Join Date: Feb 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Listbox retain value after page refresh

Hi all,

I have a list box and several buttons in my pages (asp.net + C#). When I click on one of the buttons, the page gets refreshed and the selected item in the listbox becomes reset to the first values.

How do I retain the listbox selected item value even after click the button (page refresh). The Enableviewstate of the listbox is true only. Also note, that the listbox values are dynamically populated.

Kindly help.

Regards,

tvks
 
Old March 7th, 2007, 03:44 PM
Authorized User
 
Join Date: Mar 2007
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Only populate the listbox on if not page.ispostback

so
sub page_load()
if not page.ispostback then
  pupulateListboxes
end if
end sub

Then, unless you get redirected to the page, you will always have data in your listbox, unless you call listbox.items.clear







Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retain values of dynamic controls when page fozia_izhar .NET Framework 1.x 1 February 7th, 2007 02:32 PM
Need to "Refresh" page fskilnik Dreamweaver (all versions) 3 October 20th, 2005 10:49 AM
page Refresh skicrud PHP How-To 2 August 25th, 2004 04:03 AM
Refresh Data on Page acdsky Classic ASP Basics 1 July 23rd, 2004 08:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.