title: ASP.NET PostBack on selecting checkbox of treeview
body: <p>I have an asp.net project and working in C#.</p>
  
  <p>In my project I have a databound listbox that has checkboxes.</p>
  
  <p>When the user clicks on a checkbox it should for an example update a label/textbox.</p>
  
  <p>The thing is, it doesnt update the label/textbox until I click on a button that does a postback. How will I Call a postback on the checkbox changed event, since the "OnTreeNodeCheckChanged" event looks like it only fires once the postback has been triggered?
  Is this even a good idea (to want to call a postback every time the a checkbox has been changed)</p>
  
  <p>--Updated code Snippet--
  Asp</p>
  
  <pre><code> &lt;asp:TreeView ID="treevCourses" runat="server" AutoPostBack="true" ShowCheckBoxes="All" Width="100%"
                  OnTreeNodeCheckChanged="check_changed" Height="16px" ImageSet="Contacts"&gt;
  </code></pre>
  
  <p>(Tried having the handler in the C# part.)
  C#</p>
  
  <pre><code>protected void check_changed(object sender, TreeNodeEventArgs e)
          {
          lblTest.Text = "TestText";
          }
  </code></pre>
  
  <p>(Also tried having it in the script part)</p>
  
  <pre><code>void check_changed(object sender, EventArgs e)
      {
          lblTest.Text = "TestText";
      }
  </code></pre>
  
  <p>Binding data to the Treeview (this happens on a button postback)</p>
  
  <pre><code>foreach (DataRow row in ds.Tables[0].Rows)
                  {
                      TreeNode node = new TreeNode(row["courseName"].ToString(), row["courseName"].ToString());
                      //  node.PopulateOnDemand = true;
                      treevCourses.Nodes.Add(node);
                  }
  
  
                  //select from topic where parentId = topicId.
                  ds = myConClass.returnSqlDataset("select cd.courseName,ct.[date] from courseDetails cd join courseTimes ct on cd.courseId = ct.courseId");
  
                  foreach (TreeNode treenode in treevCourses.Nodes)
                  {
                      foreach (DataRow row in ds.Tables[0].Rows)
                      {
                          if (row["courseName"].ToString() == treenode.Value)
                          {
                              TreeNode node = new TreeNode(row["date"].ToString(), row["date"].ToString());
                              treenode.ChildNodes.Add(node);
                          }
                      }       
                  }
  </code></pre>