|
-
Feb 11th, 2004, 12:41 PM
#1
Thread Starter
Hyperactive Member
Run code on page load only once
Hello,
Then page is loading (Page_Init sub), I fill my combo-box with MySQL database data.
Then I select item and press command button. Problem is that after postback function is called, Page_init sub is called again and combo box is refilled, so my selected item is canged. How to run code only once, when page is loading?
Ps. Sorry for my poor english.
Last edited by Norkis; Feb 11th, 2004 at 01:01 PM.
-
Feb 11th, 2004, 01:10 PM
#2
First - rather move the code to Page_Load, then set EnableViewState to true, and:
Code:
if (!Page.IsPostBack)
{
// Populate the control.
}
Alternatively, you could use Request.Form["ComboName"]
-
Feb 11th, 2004, 01:16 PM
#3
Thread Starter
Hyperactive Member
It worked.
Now combo isn't filled againg.
But my problem isn't solved.
Selected item refreshes to the top item.
How to keep selected items in combo boxes?
-
Feb 11th, 2004, 01:36 PM
#4
Thread Starter
Hyperactive Member
I found that combobox selection is changed only when selected item contains non standart charters (ą č ę ė etc. charset cp1257).
Isn't it a bug? How to solve this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|