Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have added an web server control in my solution where I am creating my own datalist. However I am unable to make it get its data. Here is my code in the web server control. What I am doing wrong? Please help!

XML
protected override void RenderContents(HtmlTextWriter writer)
{
    // Place some text before the DataList.
    writer.Write("Here is some text from the RenderContent method.<br>");

    // Call the base RenderContents method.

    this.RepeatDirection = RepeatDirection.Horizontal;
    this.RepeatColumns = _nofcolumns;
    writer.Write("<ItemTemplate> <%# DataBinder.Eval(Container.DataItem, \"Merhaba\")%> </ItemTemplate>");

    base.RenderContents(writer);
}


Thanks in advance!
Posted
Updated 20-Jan-11 11:20am
v2
Comments
Manfred Rudolf Bihy 20-Jan-11 19:51pm    
I'm sorry that I can't help you with that since I don't have great experience in the design of ASP.NET controls. All that I can tell you though is that the method RenderContents should be used to build the HTML output. I think what you are looking for is extending a control that already sports an ItemTemplate tag.

I'm not quite sure of what you're trying to achieve here, but I can point out a serious misconception. Your function RenderContents(HtmlTextWriter) is supposed to render (part of) your control as HTML. This is the stuff that gets sent to the client.
When I look at your writer.Write statement though it seems you want to write out code like it is found on ASPX pages:
aspx
<ItemTemplate> <%# DataBinder.Eval(Container.DataItem, \"Merhaba\")%> </ItemTemplate>"


While this kind of code is fine on ASPX pages that are compiled and run on the server side it has nothing to do with HTML.

Maybe if you explained a little more what it is that you're trying to achieve we could offer even better advice!

Modification:
I think this is a link you should study thouroghly: http://msdn.microsoft.com/en-us/library/zt27tfhy.aspx[^]
End Modification

Best regards,
Manfred
 
Share this answer
 
v3
Comments
fjdiewornncalwe 20-Jan-11 19:30pm    
OP's comment moved from answer:
Hi Manfred,
I just Realize that, what I am trying to do is to create a custom datalist that has determined number of fields as web server control.. I want to attach all these fixed features to custom datalist control thereby I would be able to set rest of the dimensions via properties. Where I could not do is to add itemtemplate to this custom datalist. There is no such thing.
Itemtemplate itm = new itemtemplate;
itm.DataBinder.Eval(Container.DataItem, "Merhaba")
this.add(itm)
Please help, I working on it for hours now
Thanks anyway, is it possible for you to suggest me a forum where I can find the answer? I have posted this question twice on this forum and could not find the answer. Also once this question is answered, nobody again responds it.

ALl the best
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900