I get the following error when I change my code to what was suggested:
Server Error in '/CPS' Application.
--------------------------------------------------------------------------------
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Specified cast is not valid.
Source Error:
Line 86: field = ""
Line 87: 'For i = 0 To ((Session("recordcount")) - 1)
Line 88: For Each chk As CheckBox In ChkLstVen.Items
Line 89: If chk.Checked Then
Line 90:
Source File: c:\inetpub\wwwroot\CPS\DataSelVen.aspx.
vb Line: 88
Stack Trace:
[InvalidCastException: Specified cast is not valid.]
CPS.DataSelVen.cmdSave_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\CPS\DataSelVen.aspx.
vb:88
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292
Did I do something wrong?