Dim Application = From AL In db.AnnualLeave _
Where AL.Approval <> True _
Select LeaveID, EmpID, Name
GridView3.DataSource = Application
GridView3.DataBind()
after calling `GridView3.DataBind()开发者_StackOverflow社区, why do i still get
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index.
at this line of code GridView3.Columns(1).Visible = False
yet the grid has rows and more than 2 columns. i found a thread about similar problem here http://forums.asp.net/t/1025678.aspx/1
Note that the Gridview columns have NOT been defined at design time. `
You need to be careful where you place your code in asp.net. If you placed that GridView3.Columns(1).Visible = False
code in the wrong place at the wrong time then yes, it would throw an error.
I suggest reading up on ASP.NET Page Lifecyle
精彩评论