I am using ASP Login feature and I am binding data for controls like repeaters and div's using the clause

if (!Page.IsPostBack)

If the login is successfull, then it seems all is fine. Otherwise, repeaters and div's etc lose their data.

I have noticed that when the login is successful, it loads the page twice, first with postback and second without postback. If the login fails, then it loads the page only once without postback.

Therefore, what is happening sort of makes sense. However, why do I need to bind data to repeaters all the time? Shouldn't I bind data only when it is not a postback? What is causing the data to unbind?

check your viewstate property of your repeaters or the entire page.
only view state prevents the page from loosing its data during requests.(the other way is session variable but it would be stupid to use it to keep data source)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.