Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <asp:UpdatePanel runat="server" ID="theUpdatePanel" UpdateMode="Conditional" ChildrenAsTriggers="True">
- <ContentTemplate>
- <asp:DropDownList runat="server" ID="theDropDownList" OnSelectedIndexChanged="theDropDownList_OnSelectedIndexChanged" EnableViewState="true" AutoPostBack="true" />
- <asp:GridView ID="theGridView" runat="server" AutoGenerateColumns="False">
- <Columns>
- ...
- </Columns>
- </asp:GridView>
- </ContentTemplate>
- </asp:UpdatePanel>
- public void theDropDownList_OnSelectedIndexChanged(object sender, EventArgs e)
- {
- //get value that is stored in theLabel - I know this value is correct every time
- int theValueFromTheLabel = Int32.Parse(theLabel.Text);
- //populate theGridView with data from the DB
- theGridView_Populate(theValueFromTheLabel);
- //update theUpdatePanel (it works for the first change whether this line is here or not)
- theUpdatePanel.Update();
- }
- protected void theGridView_Populate(int theValueFromTheLabel)
- {
- //get value from theDropDownList - this value does change when theDropDownList's value changes
- int theValueFromTheDropDownList = Int32.Parse(theDropDownList.SelectedValue);
- //get data from DB - the data here does change every time theDropDownList's value changed
- ComplexClassController controller = new ComplexClassController();
- List<ComplexClass> data = controller.GetData(theValueFromTheLabel, theValueFromTheDropDownList);
- //load theGridView - this changes the data, but doesn't refresh theGridView to be able to see it
- theGridView.DataSource = data;
- theGridView.DataBind();
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- if(!ispostback){
- Loadcomobo();
- }
- }
- <triggers>
- <asyncpostback ControlID="theDropDownList" />
- </triggers>
- </asp:UpdatePanel>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement