page reloads

G

Guest

I have the following code to populate a list box when my form opens. The
problem is that when I select something from the listbox the page reloads and
goes to the top of the page. I need it to not do that so that I can finish
filling out the form and then hit submit button.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
strconnectionstring = "Provider=sqloledb;data
source=ntserver3;initial catalog=Family_Consultation_test;user
id=sa;password=guru;"
objoledbconnection = New OleDb.OleDbConnection(strconnectionstring)
objoledbcommand = New OleDb.OleDbCommand
objoledbcommand.Connection = objoledbconnection
objoledbcommand.Connection.Open()
strsql = "select first_name + ' ' + last_name as fullname from
viewpractitioner where pers_org_term_date is null" & _
" and pract_entity_id < '800.033' or pers_org_term_date is
null and pract_entity_id > '908.033' order by last_name"
objoledbcommand.CommandText = strsql
objoledbdatareader = objoledbcommand.ExecuteReader
Me.ddlClinician.DataSource = objoledbdatareader
If Not Page.IsPostBack Then
Me.ddlClinician.DataBind()
ddlClinician.Items.Insert(0, " ")
ddlClinician.SelectedIndex = 0
objoledbdatareader.Close()
'objoledbcommand.Connection.Close()
End If
objoledbdatareader.Close()
strsql = "select * from tblMedicalNecessity"
objoledbcommand.CommandText = strsql
objoledbdatareader = objoledbcommand.ExecuteReader
lstMedNecess.DataSource = objoledbdatareader
'If Not Page.IsPostBack Then
lstMedNecess.DataBind()
lstMedNecess.Items.Insert(0, " ")
lstMedNecess.SelectedIndex = 0
'objoledbdatareader.Close()
'objoledbcommand.Connection.Close()
'End If
objoledbdatareader.Close()
objoledbcommand.Connection.Close()
End Sub
 
G

Guest

Is the AutoPostBack property of the ListBox control set to true?

If so, it should be set to false to achive the behavior you desire.

Jason Richmeier
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top