foreach statement cannot operate on variables of type 'System.Web.UI.WebControls.ListView' because 'System.Web.UI.WebControls.ListView' does not contain a public definition for 'GetEnumerator'
Cannot convert type 'System.Web.UI.WebControls.ListViewDataItem' to 'System.Web.UI.WebControls.ListItem'
'System.Web.UI.WebControls.ListItem' does not contain a definition for 'FindControl' and no extension method 'FindControl' accepting a first argument of type 'System.Web.UI.WebControls.ListItem' could be found (are you missing a using directive or an assembly
reference?)
foreach statement cannot operate on variables of type 'System.Web.UI.WebControls.ListView' because 'System.Web.UI.WebControls.ListView' does not contain a public definition for 'GetEnumerator'
SudhaRubini
Member
391 Points
383 Posts
Error for cannot operate on variables of type in listview
Apr 26, 2012 07:08 AM|LINK
Hi
i got this error
how to slove it
foreach statement cannot operate on variables of type 'System.Web.UI.WebControls.ListView' because 'System.Web.UI.WebControls.ListView' does not contain a public definition for 'GetEnumerator'
my code is
foreach (ListItem Item in lstCourseNews)
{
Label lblData = (Label)lblData;
lblData.Text = Server.HtmlDecode(lblData.Text);
}
somnathmali
Contributor
2816 Points
450 Posts
Re: Error for cannot operate on variables of type in listview
Apr 26, 2012 07:12 AM|LINK
foreach (ListItem Item in lstCourseNews.Items) {also use findControl
Label lblData = item.FindControl("yourcontrolID") as Label; lblData.Text = Server.HtmlDecode(lblData.Text); }.NET Developer , Pune INDIA.
Please Mark As Answer If my reply helped you.
SudhaRubini
Member
391 Points
383 Posts
Re: Error for cannot operate on variables of type in listview
Apr 26, 2012 07:23 AM|LINK
Hi
i add lstcourseNews.items
i got this error
Cannot convert type 'System.Web.UI.WebControls.ListViewDataItem' to 'System.Web.UI.WebControls.ListItem'
'System.Web.UI.WebControls.ListItem' does not contain a definition for 'FindControl' and no extension method 'FindControl' accepting a first argument of type 'System.Web.UI.WebControls.ListItem' could be found (are you missing a using directive or an assembly reference?)
plz help me. how to reslove this
ramiramilu
All-Star
95503 Points
14106 Posts
Re: Error for cannot operate on variables of type in listview
Apr 26, 2012 07:44 AM|LINK
Iterate listview items - http://chanmingman.wordpress.com/2011/02/12/loop-iterate-through-listview-items-asp-net-code-and-video/
Thanks,
JumpStart
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: Error for cannot operate on variables of type in listview
Apr 30, 2012 10:23 AM|LINK
foreach (ListViewItem lvItem in lstCourseNews.Items) { Label lblData = (Label)lblData; lblData.Text = Server.HtmlDecode(lblData.Text); }Feedback to us
Develop and promote your apps in Windows Store