asp.net article ascx databinding


Author Message
Roberto

Posted: 5/21/2009
Quote message 

hello everyone, I have a problem with the user control artisteer: Article in asp.net 3.5.

I can not do databinding with the property "Caption"
in debug mode, in the public class Article : WebControl the variable string _caption is populated by the property set, but these are not displayed. Any ideas?

I use the artisteer: Article into the asp:Repeater control and this is my code.

tank you very much for attention and I very happy to use your product!
 
roberto

Posted: 5/21/2009
Quote message 

ok I created a workaround for resolve my problem, but you create a new webControl for databinding? very sorry for my bad english.

1) add new method at your class Article.cs

protected override void DataBindChildren()
{
base.DataBindChildren();
(_headerPlaceholder.FindControl("lblCap") as Label).Text = _caption;

}
2) I modify you code in CreateChildControls() the original Literal isn't removed for you

protected override void CreateChildControls()
{
Controls.Clear();

articleMarkup = Page.LoadControl("~/Design/Article.ascx");

_headerPlaceholder = articleMarkup.FindControl("HeaderPlaceholder") as PlaceHolder;
_contentPlaceholder = articleMarkup.FindControl("ContentPlaceholder") as PlaceHolder;

//_headerPlaceholder.Visible = ! String.IsNullOrEmpty(_caption);


if (true)
{
Label lblCaption = new Label();
lblCaption.Text = _caption;
lblCaption.ID = "lblCap";
Literal caption = new Literal();
caption.Text = _caption;
caption.ID = "caption";
_headerPlaceholder.Controls.Add(caption);
_headerPlaceholder.Controls.Add(lblCaption);
}