Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Need help developing webpart - gridview and itemtemplates... View modes: 
User avatar
Member
Member
Ernesto - 10/23/2009 1:07:03 PM
   
Need help developing webpart - gridview and itemtemplates...
Hello,
i am still a newbie when developing under ASP.NET.

I am coding a webpart
The class definition is this:
public partial class CMSWebParts_OurWebParts_OurEmployeeList : CMSAbstractWebPart

In the .aspx page i use a GridView and i want to do something like this :

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="Number" DataSourceID="SqlDataSourcevueContactsTriesWebRecherche">
<Columns>
<asp:TemplateField HeaderText="Number" InsertVisible="False">
<ItemTemplate>
<% =ReturnName(DataBinder.Eval(Container.DataItem, "Number").ToString())%>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

However, i can't seem to use Container.DataItem.

I get a message from intellisense telling me :
'CMS.PortalEngine.WebPartContainerInfo' does not contain a definition for 'DataItem

I have tried so many different things. A bit of help will be most welcome.

User avatar
Member
Member
Ernesto - 10/23/2009 2:36:08 PM
   
RE:Need help developing webpart - gridview and itemtemplates...
Ok, i wasted so much time on this but finally found the solution just a little time after posting here.

<% =ReturnName(DataBinder.Eval(Container.DataItem, "Number").ToString())%>

can be replaced by one or the other of those :

<%# ReturnName(DataBinder.Eval(Container.DataItem, "Number").ToString())%>
<%# ReturnName(Eval("Number").ToString())%>

Small syntax difference makes big changes...


User avatar
Kentico Support
Kentico Support
kentico_radekm - 10/29/2009 3:36:31 PM
   
RE:Need help developing webpart - gridview and itemtemplates...
Hello Ernesto.

Thank you for post here a solution also for other users, which could encounter a similar issue.

Best Regards,
Radek Macalik
Support Engineer