I have a number of templates applied to provide property labels on certain nodes like below. So that even when Property 2 for instance has no value, it's still labeled as such by the template.
Item1
Property 1: Property1Value
Property 2:
Item 2
This works fine when editing one of the property nodes that already has a value like Property 1. But when editing an empty node like Property 2, instead of just showing a blank edit box, you would see the label in there like "Property 2: ". Then it passes the whole thing as the text in the event args to the NodeEdit handler rather than just the entered value. So you get "Property 2: Prop2value" rather than just "Prop2Value".
I've tried it like below and also breaking out the wrapping tag for the value into a second label and setting the DataBinding handler on that. I get the same result either way. Am I missing something or is this a bug?
also
Item1
Property 1: Property1Value
Property 2:
Item 2
This works fine when editing one of the property nodes that already has a value like Property 1. But when editing an empty node like Property 2, instead of just showing a blank edit box, you would see the label in there like "Property 2: ". Then it passes the whole thing as the text in the event args to the NodeEdit handler rather than just the entered value. So you get "Property 2: Prop2value" rather than just "Prop2Value".
I've tried it like below and also breaking out the wrapping tag for the value into a second label and setting the DataBinding handler on that. I get the same result either way. Am I missing something or is this a bug?
public class Property2Template : ITemplate
{
public void InstantiateIn(Control container)
{
Label label1 = new Label();
RadTreeNode node = (RadTreeNode)container;
label1.Text = "Property 2: <
span
class=\"PropertyValue\">" + node.Text + "</
span
>";
label1.CssClass = "PropertyLabel";
container.Controls.Add(label1);
}
}
also
public class Property2Template : ITemplate
{
public void InstantiateIn(Control container)
{
Label label1 = new Label();
Label label2 = new Label();
RadTreeNode node = (RadTreeNode)container;
label1.Text = "Property 2: ";
label1.CssClass = "PropertyLabel";
label2.Text = node.Text;
label2.CssClass = "PropertyValue";
label2.DataBinding += new EventHandler(label2_DataBinding);
container.Controls.Add(label1);
container.Controls.Add(label2);
}
public void label2_DataBinding(object sender, EventArgs e)
{
Label target = (Label)sender;
RadTreeNode node = (RadTreeNode)target.BindingContainer;
string nodeText = (string)DataBinder.Eval(node, "Text");
target.Text = nodeText;
}
}