Container.DataItem in ASCX problem

O

OrlandoRocks

I am trying to use a templated column in a datagrid and having no
luck, here is the code of both the calling page and the ascx page.

..vb

Dim MyConnection As SqlClient.SqlConnection = New
SqlClient.SqlConnection("Database=workflow;uid=sa;pwd=newlife")
Dim custCMD As SqlClient.SqlCommand = New
SqlClient.SqlCommand("Select * from forma", MyConnection)
MyConnection.Open()
Dim myReader As SqlClient.SqlDataReader =
custCMD.ExecuteReader()
Dim temp As ITemplate =
Page.LoadTemplate("webusercontrol4.ascx")
Dim TemplateColunn As TemplateColumn
Dim tc As New TemplateColumn
tc.HeaderText = "Last Name"
tc.ItemTemplate = temp
DataGrid1.Columns.Add(tc)
DataGrid1.DataSource = myReader
DataGrid1.DataMember = "forma"
DataGrid1.DataBind()

..ascx

<%@ Control Language="vb" %>
<asp:Label id=Label1 runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "lastname")%>'>
</asp:Label>

I get this error message

BC30456: 'DataItem' is not a member of 'System.Web.UI.Control'.

I know it's probably something simple any ideas?

Russ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top