471,309 Members | 1,042 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,309 software developers and data experts.

Problems with properties on WebUserControl and Repeater

Hi,

I have created a little WebUserControl "SelectTemplate.ascx" which defines a
property

public class SelectTemplate : System.Web.UI.UserControl
{
public int PublisherType
{
get;
set;
}
}

On my form, I want to have a repeater which creates for each value in a
collection of "Publisher" items (=DataSource) a SelectTemplate control and
set the PublisherType property to the value of the corresponding property in
a Publisher.

public class Publisher
{
public int PublisherType
{
get;
set;
}
}

I added a repeater to my form and changed to code behind to edit Page_Load
as followed:
public void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
Repeater1.DataSource = _Publishers; // _Publishers actually is
stored in the session state
Repeater1.DataBind();
}
}

Then I switched to html view and edited the InnerTemplate of the repeater:
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<uc1:SelectTemplate id="SelectTemplate1" runat="server"
PublisherType="<%# DataBinder.Eval(Container.DataItem, "PublisherType"
%>"></uc1:SelectTemplate>
</ItemTemplate>
</asp:Repeater>

Unfortunateley, when executing the code, I get the following - quite
uninformational error:
Parser-Error: Servertag not formatted property

Sorry, I am having german version of .NET installed, so I had to translate
to english. The german message sounds as follows:
Parser-Fehlermeldung: Servertag wurde falsch formatiert.

Can somebody help me out?

Regards,
Michael
Nov 19 '05 #1
2 1506
I think there is a problem with you " around publisher type in your
ItemTemplate definition

PublisherType="<%# DataBinder.Eval(Container.DataItem, "PublisherType" %>">

Try using

PublisherType='<%# DataBinder.Eval(Container.DataItem, "PublisherType" %>'>

Notice I changed the outer quotes to a single quote.

bill

Dein English ist sehr gut!

"Michael Groeger" <go*********@web.de> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

I have created a little WebUserControl "SelectTemplate.ascx" which defines a property

public class SelectTemplate : System.Web.UI.UserControl
{
public int PublisherType
{
get;
set;
}
}

On my form, I want to have a repeater which creates for each value in a
collection of "Publisher" items (=DataSource) a SelectTemplate control and
set the PublisherType property to the value of the corresponding property in a Publisher.

public class Publisher
{
public int PublisherType
{
get;
set;
}
}

I added a repeater to my form and changed to code behind to edit Page_Load
as followed:
public void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
Repeater1.DataSource = _Publishers; // _Publishers actually is
stored in the session state
Repeater1.DataBind();
}
}

Then I switched to html view and edited the InnerTemplate of the repeater:
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<uc1:SelectTemplate id="SelectTemplate1" runat="server"
PublisherType="<%# DataBinder.Eval(Container.DataItem, "PublisherType"
%>"></uc1:SelectTemplate>
</ItemTemplate>
</asp:Repeater>

Unfortunateley, when executing the code, I get the following - quite
uninformational error:
Parser-Error: Servertag not formatted property

Sorry, I am having german version of .NET installed, so I had to translate
to english. The german message sounds as follows:
Parser-Fehlermeldung: Servertag wurde falsch formatiert.

Can somebody help me out?

Regards,
Michael

Nov 19 '05 #2
Hi Bill,
Try using

PublisherType='<%# DataBinder.Eval(Container.DataItem, "PublisherType" %>'>

Correct! Now it works, thank you.
Dein English ist sehr gut! Thank you ;) Does this mean that I translated the german text properly or do
you mean my english at all? ;)

Regards,
Michael

"Michael Groeger" <go*********@web.de> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi,

I have created a little WebUserControl "SelectTemplate.ascx" which defines
a
property

public class SelectTemplate : System.Web.UI.UserControl
{
public int PublisherType
{
get;
set;
}
}

On my form, I want to have a repeater which creates for each value in a
collection of "Publisher" items (=DataSource) a SelectTemplate control
and set the PublisherType property to the value of the corresponding property in
a Publisher.

public class Publisher
{
public int PublisherType
{
get;
set;
}
}

I added a repeater to my form and changed to code behind to edit

Page_Load as followed:
public void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
Repeater1.DataSource = _Publishers; // _Publishers actually is
stored in the session state
Repeater1.DataBind();
}
}

Then I switched to html view and edited the InnerTemplate of the repeater: <asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<uc1:SelectTemplate id="SelectTemplate1" runat="server"
PublisherType="<%# DataBinder.Eval(Container.DataItem, "PublisherType"
%>"></uc1:SelectTemplate>
</ItemTemplate>
</asp:Repeater>

Unfortunateley, when executing the code, I get the following - quite
uninformational error:
Parser-Error: Servertag not formatted property

Sorry, I am having german version of .NET installed, so I had to translate to english. The german message sounds as follows:
Parser-Fehlermeldung: Servertag wurde falsch formatiert.

Can somebody help me out?

Regards,
Michael


Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by DichkoSoft | last post: by
2 posts views Thread by Oren | last post: by
2 posts views Thread by Oren | last post: by
reply views Thread by riddion | last post: by
reply views Thread by Giovanni | last post: by
reply views Thread by Terry Olsen | last post: by
reply views Thread by Klaus Jensen | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.