Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problems with properties on WebUserControl and Repeater

Reply
Thread Tools

Problems with properties on WebUserControl and Repeater

 
 
Michael Groeger
Guest
Posts: n/a
 
      05-04-2005
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


 
Reply With Quote
 
 
 
 
William F. Robertson, Jr.
Guest
Posts: n/a
 
      05-04-2005
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Michael Groeger
Guest
Posts: n/a
 
      05-09-2005
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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WebUserControl and vs2008 properties window Andy B ASP .Net 1 06-07-2008 09:12 AM
WebUserControl's bindable properties not seen in GridView's Bindable Properties list Craig Buchanan ASP .Net Web Controls 0 08-22-2007 04:04 PM
WebUserControl Events & Properties? Terry Olsen ASP .Net 0 09-07-2006 02:06 AM
WebUserControl/ascx Properties window jgrant ASP .Net Building Controls 0 02-15-2006 05:31 PM
Problems parsing when Properties.dtd.properties Kent Lichty Java 0 04-16-2004 03:08 PM



Advertisments