Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want following event fire on page load.
C#
protected void ddlSelectSector_SelectedIndexChanged(object sender, EventArgs e)
        {
            int sectorId = SafeConvert.ToInt32(ddlSelectSector.SelectedValue);
            var empList = _service.GetEmployeeDutyByToSector_Id(sectorId).Where(x => x.EndDate <= DateTime.Today && x.ToSector_Id == sectorId).ToList();
            ddlRollNo.Bind(empList, "EmployeeIdName", "Employee_Id");
           
        }
Posted
Comments
[no name] 25-Mar-15 5:59am    
call ur dropdownmethod in page load..
[no name] 25-Mar-15 6:06am    
Yes call your drop-downs method in page load, why do you want to use select changed event? do you want to cascading dropdowns?
Rajesh Buddaraju 25-Mar-15 11:28am    
put the selectedindexedchanged code in a separate method and call the same method in pageload and selectedindexedchanged. Why you want to call the event in page load any specific scenario let us know
Sajid227 26-Mar-15 1:04am    
i want that when an employee login ,then base on his last sector record ,sector must be selected auto,and and user can not change it.

1 solution

Keep this event handler as it is.

Now bind the dropdown 'ddlSelectSector' in page load, set its default value just after binding it within same page load and load the 'ddlRollNo' dropdown on its selected value in same page load.

Further 'ddlRollNo' will be always rebound on first dropdown selection change due to the above selectedindex change event handler.


Hope this works for you, please give more details id this does not help you.
 
Share this answer
 
Comments
Sajid227 26-Mar-15 1:07am    
sir i have the following scenario, i want that when a user login in base on his last record from employee duty table in ddlsector that sector must be selected and user can not change it
SRS(The Coder) 26-Mar-15 12:04pm    
then whats the problem just populate the ddlSector on page load event handler of the page, and set its value within it as well. Then make it read only or disabled and populate the secondary dropdown on its selected value if needed.
Sajid227 27-Mar-15 0:26am    
thanx bro i got this idea
SRS(The Coder) 27-Mar-15 0:32am    
always welcome :)

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