protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { if(e.Row.RowIndex >2) { e.Row.Attributes.Add("style", "display:none"); } } }
protected void newestListView_ItemDataBound(object sender, ListViewItemEventArgs e) { if (newestListView.Items.DataItemIndex > 3) { e.Items.Attributes.Add("style", "display:none;"); } }
Compiler Error Message: CS1061: 'System.Collections.Generic.IList<System.Web.UI.WebControls.ListViewDataItem>' does not contain a definition for 'DataItemIndex' and no extension method 'DataItemIndex' accepting a first argument of type 'System.Collections.Generic.IList<System.Web.UI.WebControls.ListViewDataItem>' could be found (are you missing a using directive or an assembly reference?) Kindly help me with proper code. I am using ASP.NET C# Many thanks for your help What I have tried: I have tried Index , DataItme Index also in place of ItemIndex but it did not work
ListViewDataItem dataItem = (ListViewDataItem)e.Item
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)