Datalist nested Treeview

Source: Internet
Author: User

Datalist nest Treeview and execute the Treeview selection event.

 

Code
<% @ Page Language = " C # " Autoeventwireup = " True " Codefile = " Treedemo. aspx. CS " Inherits = " Treedemo "   %>

<!Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

< Html Xmlns = "Http://www.w3.org/1999/xhtml" >
< Head Runat = "Server" >
< Title > </ Title >
</ Head >
< Body >
< Form ID = "Form1" Runat = "Server" >
< Div >

</ Div >
< ASP: datalist ID = "Datalist1" Runat = "Server"  
Onitemdatabound = "Datalistpolicitemdatabound" >
< Itemtemplate >
Aaaaaaaaaa
< ASP: Treeview ID = "Tree" Runat = "Server"  
Onselectednodechanged = "Tree_selectednodechanged"   > </ ASP: Treeview >
</ Itemtemplate >
</ ASP: datalist >

</ Form >
</ Body >
</ Html >

 

 

The day after tomorrowCode

 

Code
Using System;
Using System. Collections. Generic;
Using System. LINQ;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. webcontrols;
Using System. Data;

Public   Partial   Class Treedemo: system. Web. UI. Page
{
Protected   Void Page_load ( Object Sender, eventargs E)
{
If ( ! Ispostback)
{
Datatable dt =   New Datatable ();
DT. Columns. Add ( " Name " );
Datarow Dr = DT. newrow ();
Dr [ " Name " ] =   " Ayi " ;

DT. Rows. Add (DR );

Datalist1.datasource=DT;
Datalist1.databind ();
}
}

Protected   Void Tree_selectednodechanged ( Object Sender, eventargs E)
{
Treeview TV = (Treeview) sender;
Response. Write (TV. selectedvalue );
}
Protected   Void Datalist1_itemdatabound ( Object Sender, datalistitemeventargs E)
{
If (E. Item. itemindex ! =   - 1 )
{
Treeview TV = (Treeview) E. Item. findcontrol ( " Tree " );

treenode node = New treenode ();
node. text = " test " ;
node. value = " 1 " ;

TV. nodes. Add (node);
}< BR >}< br>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.