Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. <asp:UpdatePanel runat="server" ID="theUpdatePanel" UpdateMode="Conditional" ChildrenAsTriggers="True">
  2. <ContentTemplate>
  3. <asp:DropDownList runat="server" ID="theDropDownList" OnSelectedIndexChanged="theDropDownList_OnSelectedIndexChanged" EnableViewState="true" AutoPostBack="true" />
  4. <asp:GridView ID="theGridView" runat="server" AutoGenerateColumns="False">
  5. <Columns>
  6. ...
  7. </Columns>
  8. </asp:GridView>
  9. </ContentTemplate>
  10. </asp:UpdatePanel>
  11.  
  12. public void theDropDownList_OnSelectedIndexChanged(object sender, EventArgs e)
  13. {
  14. //get value that is stored in theLabel - I know this value is correct every time
  15. int theValueFromTheLabel = Int32.Parse(theLabel.Text);
  16.  
  17. //populate theGridView with data from the DB
  18. theGridView_Populate(theValueFromTheLabel);
  19.  
  20. //update theUpdatePanel (it works for the first change whether this line is here or not)
  21. theUpdatePanel.Update();
  22. }
  23.  
  24. protected void theGridView_Populate(int theValueFromTheLabel)
  25. {
  26. //get value from theDropDownList - this value does change when theDropDownList's value changes
  27. int theValueFromTheDropDownList = Int32.Parse(theDropDownList.SelectedValue);
  28.  
  29. //get data from DB - the data here does change every time theDropDownList's value changed
  30. ComplexClassController controller = new ComplexClassController();
  31. List<ComplexClass> data = controller.GetData(theValueFromTheLabel, theValueFromTheDropDownList);
  32.  
  33. //load theGridView - this changes the data, but doesn't refresh theGridView to be able to see it
  34. theGridView.DataSource = data;
  35. theGridView.DataBind();
  36. }
  37.  
  38. protected void Page_Load(object sender, EventArgs e)
  39. {
  40. if(!ispostback){
  41. Loadcomobo();
  42. }
  43. }
  44.  
  45. <triggers>
  46. <asyncpostback ControlID="theDropDownList" />
  47. </triggers>
  48.  
  49. </asp:UpdatePanel>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement