there are some item in my database,on page load, my dropdownlist will load all the item from db, what i want to achieve is whenever user selected any item from dropdownlist, there are some output will be display
item inside my db
a
b
c
once i set dropdownlist auto post back =true (it can achieve one of my requirement, once there are item selected, some output display, but there are problems for data load)
output in dropdownlist
a
b
c
a
b
c
a
b
c
it will repeated for 3 time
once i set autopostback =false (data load no problem,but cant display my output)
below is the code for my dropdownlist
while (dtrLoad.Read())
{
ddlCourse.Items.Add(dtrLoad["subject"].ToString());
if(ddlCourse.SelectedItem.Text=="Please Select"){
p1.InnerHtml = "Welcome";
}else if(ddlCourse.SelectedItem.Text==dtrLoad["subject"].ToString()){
p1.InnerHtml=dtrLoad["subjectIntroduction"].ToString();
}else{
}
}
It’s required to trigger page update, to reflect any changes on the page.
It is possible with button click or with dropdown itself.
Try to set “AutoPostBack” property of the dropdown to true.