Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

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

  Asked By: Binge    Date: Feb 04    Category: Asp.net    Views: 2107
  

I am trying to display the list of products that are available in
the database using Dataadapter, Dataset and I am getting the above
error.The error is showing at the html part of the code.Please help
me.
if not page.IsPostBack then


'populate grid
dim da as new SQLDataAdapter()
dim ds as new DataSet()

da.selectcommand=new sqlcommand("select * from
products",con)
da.fill(ds,"products")
datalist1.datasource = ds.tables("products")
datalist1.databind()
end if
end sub

<asp:label id="lblpname" runat="server" text='<%# container.DataItem
("pname")%>'></asp:label>

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Tracy Myers     Answered On: Feb 04

use:
<%# DataBinder.Eval(Container.DataItem, "pname") %>
and make sure your Label control  lblpname is within your DataList1 web  control.

 
Answer #2    Answered By: Vonda Ramirez     Answered On: Feb 04

I had this problem before. This error  occurs when your control  is not in
Datagrid, datalist or repeater. Make sure put your control correctly.

 
Didn't find what you were looking for? Find more on 'DataItem' is not a member of 'System.Web.UI.Control'. Or get search suggestion and latest updates.




Tagged: