Click here to Skip to main content
15,888,590 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have server side droppdown it does not keeping value on post back when i am clicking on button
please help
Posted
Comments
walterhevedeich 25-Jul-11 3:59am    
You might be rebinding your data source during postback. You can post your code so we can better understand your problem.
Uday P.Singh 25-Jul-11 4:01am    
can you post your drop down code here, so that we can help you better
mayur csharp G 25-Jul-11 4:02am    
yes i am rebinding code in this way
what will be the solution
If IsPostBack = False Then
With ddldepository
.DataSource = Clsdbapplvl.FillCompExch(Session("Roleid"), "", Request("SCRID").ToString, "Y", Convert.ToString(Request("seldate")))
.DataTextField = "comp_name"
.DataValueField = "id"
.DataBind()
.SelectedIndex = 0


' txtfromdt.Value = Convert.ToString(Request.QueryString("date"))
End With
End If

You are probably binding your Dropdown to your database in Page_Load event without checking Page.IsPostBack. Try this

C#
void Page_Load (........) {
    if (!this.IsPostBack) {
        //Data Bind Dropdown here
    }
}
 
Share this answer
 
Comments
mayur csharp G 25-Jul-11 4:41am    
you mean to say i should bind dropdown here
if (!this.IsPostBack) {
//here?
}
[no name] 25-Jul-11 14:17pm    
Yes.
Hi,


What i understand from your question is that you did'nt get the databse value in to the dropdown after a postback.The sollution is you need to bind the data in postback and in not postback.

if any doubt in this please make comment on it.
regards,
shefeek
 
Share this answer
 
Hi,

By reading this Question,you are facing the problem like this i think,you bend to items into the dropdownlist, if any post back is occurred that time you are not geting that value what you selected.if it is you problem means.

use this way

1.add headden filed

2.create one javascript mathod and take dropdownlist value into headden filed value and then you use where you need that (dropdownlist value) by using headden filedvalue..

Thanks,
Naresh.G
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900