TreeView com checkbox

<< Click to Display Table of Contents >>

Navigation:  ASP.NET > ASP Controls >

TreeView com checkbox

Previous pageReturn to chapter overviewNext page

Imagem

 

treeview

 

Default.aspx

 

<div>  

      <asp:TreeView ID="TreeView1" runat="server" ShowCheckBoxes="All"

          ShowLines="True">

          <Nodes>

              <asp:TreeNode Text="Mercado" Value="Mercado">

                  <asp:TreeNode Text="Giassi" Value="Giassi"></asp:TreeNode>

                  <asp:TreeNode Text="Angeloni" Value="Angeloni"></asp:TreeNode>

              </asp:TreeNode>

              <asp:TreeNode Text="Posto" Value="Posto">

                  <asp:TreeNode Text="Esso" Value="Esso"></asp:TreeNode>

                  <asp:TreeNode Text="Ipiranga" Value="Ipiranga"></asp:TreeNode>

                  <asp:TreeNode Text="BR" Value="BR"></asp:TreeNode>

              </asp:TreeNode>

          </Nodes>

      </asp:TreeView>

      <br />

      <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Ver marcados" />

      <br />

      <br />

      <asp:ListBox ID="ListBox1" runat="server" Height="135px" Width="146px">

      </asp:ListBox>

   

  </div>

 

 

Default.aspx.cs

 

protected void Button1_Click(object sender, EventArgs e)

{

   ListBox1.Items.Clear();

  foreach (TreeNode no in TreeView1.CheckedNodes)

       ListBox1.Items.Add(no.Text);

}