|
Rank: Newbie Groups: Member
Joined: 9/26/2008 Posts: 2
|
Hi, My problem is that I have a treeview where I use the TemplateItem to bind. This is Ok, but now the drag and drop stopped. Can anyone help me? My code has showe above. Thanks,
Code: HTML/ASPX
<TopGroup Style-CssText="background-image:url(00020005);border-left-color:#e0e0e0;border-left-style:solid;border-left-width:1px;border-right-color:#e0e0e0;border-right-style:solid;border-right-width:1px;border-top-color:#e0e0e0;border-top-style:solid;border-top-width:1px;cursor:hand;font-family:Verdana;font-size:11px;padding-bottom:2px;padding-left:10px;padding-right:10px;padding-top:2px;">
<TemplateItem>
<CustomItem>
<asp:CheckBox CssClass="normal" Runat="server" Text='<%#((DataRowView)Container.DataItem)["Country"]%>' style="white-space:nowrap" ID="Checkbox1">
</asp:CheckBox>
</CustomItem>
<SubMenu>
<TemplateItem>
<CustomItem>
<asp:CheckBox CssClass="normal" Runat="server" Text='<%#((DataRowView)Container.DataItem)["State"]%>' style="white-space:nowrap" ID="Checkbox2">
</asp:CheckBox>
</CustomItem>
<SubMenu>
<TemplateItem>
<CustomItem>
<asp:CheckBox CssClass="normal" Runat="server" Text='<%#((DataRowView)Container.DataItem)["City"]%>' style="white-space:nowrap" ID="Checkbox3">
</asp:CheckBox>
</CustomItem>
</TemplateItem>
</SubMenu>
</TemplateItem>
</SubMenu>
</TemplateItem>
</TopGroup>
Code: C#
List<Cliente> lis = new List<Cliente>();
lis.Add(new Cliente("A", "B", "C", new CC("NOME")));
lis.Add(new Cliente("A1", "B3", "Cd", new CC("NOME1")));
lis.Add(new Cliente("A2", "B4", "Cx", new CC("NOME2")));
TreeView1.DataSource = lis;
TreeView1.DataFields = "A|B|Clc.Nome";
TreeView1.DataBind();
public class CC
{
string nome;
public CC(string pn)
{
Nome = pn;
}
public string Nome
{
get { return nome; }
set { nome = value; }
}
}
public class Cliente
{
CC clc;
public CC Clc
{
get { return clc; }
set { clc = value; }
}
string a;
public string A
{
get { return a; }
set { a = value; }
}
string b;
string c;
public string B
{
get { return b; }
set { b = value; }
}
public string C
{
get { return c; }
set { c = value; }
}
public Cliente(string pA, string pB, string pC, CC ccc)
{
A = pA;
B = pB;
C = pC;
Clc = ccc;
}
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
Hi,
I am not sure whether CustomItem works with drag and drop. But why do you use CustomItem for this? The TreeView supports built-in checkboxes. Just set the TreeView's CheckBoxImages.Visible to True.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 9/26/2008 Posts: 2
|
Hi,
I'm sorry but I need this because a have a hierachical objects and the data fields don't work. I tried to use TreeView1.DataFields = "A|B|Clc.Nome" but the last field don't work. Have another way to bind this objects?
Thanks,
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
Hi,
I don't think CustomItem would address the DataField issue for you. To address the DataField issue, you would add another property to your Cliente class so that you don't use "c.Nome", but use one property such as "C_Nome".
Thanks
|
|