ghanshyam.mirani
ghanshyam.mirani

Reputation: 3101

issue related to autopostback in DropDownList

I have dropdownlist and set autopostback Property to true.. the problem is that i when i change index of dropdown list Page gets postback. After Completion of Page load index of dropdown goes to 0 automatically.

How can i remain index of dropdownlist after POstback

Thanks.

Upvotes: 1

Views: 434

Answers (4)

You can bind the drop down only in the page load.

if(Page.IsPostBack == false) //page is loading first time
{
    //you can do your coding here.
}

for more infor refer to what is Ispostback == false ?

EDIT:

You have to set DataValueField and DataTextField of the dropdown list, before binding the dropdownlist may be.

Upvotes: 1

Nalaka526
Nalaka526

Reputation: 11464

Check weather the ViewState is enabled for the dropdown control & web page.

Upvotes: 3

COLD TOLD
COLD TOLD

Reputation: 13569

  if (!Page.IsPostBack)
        {
          // get selected value 
        }

or (Page.IsPostBack)

{
   //get selected value
}

not sure how you use it but you have to control postback

Upvotes: 1

Pranay Rana
Pranay Rana

Reputation: 176886

Check that you are not binding you check box again

to bind dropdownbox one time write code

if(!IsPostBack)
{
  //bind you drop downbox 
}

Upvotes: 1

Related Questions