Post Back Problem

G

Guest

Dear All,

I have a search form which has 3 drop down boxes dropID ,dropPostCode,
dropName. when I select some thing in the dropID name lets say 0001 I press
go button.It displays a Record of the employes personal details like name,age
adress etc.Now the problem is when I edit the name of the employee. I want
the name to be changed in the search form dropName dropdownbox also. For
this purpose I have written a Javascript Code in my edit button:

Dim strJavaScript As String

strJavaScript = "<script
language='javascript'>window.opener.execScript(""__doPostBack('LinkButton2','')"",""JavaScript"");</script>"
Page.RegisterStartupScript("", strJavaScript)

where LinkButton 2 is an invisible control on the search screen.So when I
edit a name of the employee and go back to search form. I can see the name
changed in dropName thats fine . But the problem is that in dropID I can see
the old name being displayed . The dropID is only meant to display the IDs of
the employees, so why is it displaying the oldName of the employee.bellow is
the code I have written in the invisible Link2Button on the search form:

Dim conHcpMain1 As SqlConnection
Dim strHcpMain1 As String
Dim cmdHcpMain1 As SqlCommand
Dim dtrHcpMain1 As SqlDataReader
Dim cmdIDs1 As SqlCommand

conHcpMain1 = New SqlConnection(Application("strConnection"))
conHcpMain1.Open()
strHcpMain1 = "Select * from HCP_FullNames"
cmdHcpMain1 = New SqlCommand(strHcpMain1, conHcpMain1)
dtrHcpMain1 = cmdHcpMain1.ExecuteReader

cboName.DataSource = dtrHcpMain1
cboName.DataTextField = "FullName"
cboName.DataValueField = "Hcp_Id"
cboName.DataBind()
dtrHcpMain1.Close()

Dim dtrIDs As SqlDataReader

cmdIDs1 = New SqlCommand("Select * from HCP_FullNames", conHcpMain1)
dtrIDs = cmdIDs1.ExecuteReader()

cboID.DataSource = dtrIDs
cboID.DataTextField = "Hcp_Id"
cboID.DataValueField = "FullName"

cboID.DataBind()
dtrIDs.Close()


It is changing the Name in the dropName Box. But for some reason it is
displaying the OLDNAME of the employee in the dropID Box.What I want
is when I edit the name of the employee I press edit button ,I go
back to
search screen. I should see only the ID of the employee in the dropID
not his previous name.

Any help would be greatly appreciated.

cheers,
Sunil Sabir
 
O

Ollie Riches

this sounds like a viewstate problem, you might be changing the value in the
drop down list with client side javascript but when the page is poated back
to the server the value that appears in the code behind implementation comes
from the viewstate not the value written by the client side javascript.

HTH

Ollie Riches

Sunil Sabir said:
Dear All,

I have a search form which has 3 drop down boxes dropID ,dropPostCode,
dropName. when I select some thing in the dropID name lets say 0001 I press
go button.It displays a Record of the employes personal details like name,age
adress etc.Now the problem is when I edit the name of the employee. I want
the name to be changed in the search form dropName dropdownbox also. For
this purpose I have written a Javascript Code in my edit button:

Dim strJavaScript As String

strJavaScript = "<script
language='javascript'>window.opener.execScript(""__doPostBack('LinkButton2',
 

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

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,242
Latest member
KendrickKo

Latest Threads

Top