Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a dropdownlist in a master page, and a gridview in a seperate content web page. When a user selects any item from the dropdownlist (I set autopostback = true), I need to refresh the Gridview based on the selected value of the dropdownlist. How can I get this to work?
Posted

I've not used MasterPage but it shouldn't be that different from other things I've done.

Your page basically inherits from the MasterPage. So make sure you do not have any SelectionChanged event coded within the master page.

In you own page you should bind that event to a method in each page that does the datagrid population.

Take this advice with a grain of salt as anything I can do in any other paradigm does not always work in the web unless you use Silverlight.
 
Share this answer
 
Hi,

You can access the master page from the child page by adding an

<%@ MasterType VirtualPath="~/pathtomaster/nameofmaster.master">

to the child page's markup. This allows you to reference the master page as a strongly typed object.

In the master page add a public readonly property for the selected value of the drop down list, i.e. dl1selectedvalue.

In the child page, during page load, update the gridview's datasource to use the value of master.dllselectedvalue, then databind the gridview.

I hope this helps.
 
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