Monday, February 20, 2006

Page.IsPostBack Property

I have to admit I am pretty new to the Asp.Net since most of my work are server-side service programming, or components programming. I get exposed to the Asp.Net since a couple of our freinds want to design a restaurant webiste where people can search enough information before going to a restaurant.

One thing which confused me a bit is when I designed a dropdownlist control to let people select the item, it appears to me that the selection is always get reset when I click on the button. The symptom is that the first item is selected everytime.

It seems that when the page is posted back, the drop down list is always get reset, so the simple trick is to check this :
if (!Page.IsPostBack)
{
//do the actual data binding.
}

No comments: