Get Line number where exception has occurred using C# and VB.Net in ASP.Net

Last Reply 2 months ago By dharmendr

Posted 2 months ago

hello,

 

i have over 100 controls in a form which has checkbox, checkboxlist, radio button date time etc.

 

for checkbox i have bit datatype in database, all fields in the form are not required so user can fill some of the fields and submit. my insert code is in try and catch block problem is when user fills all the fields it submits the form but if some of the fields are blank i get error "input is not in correct format" how can i get the control names or values which are not in correct format so i can fix that bcs it is very difficult to check over 100 controls

 

please advice


Posted 2 months ago

You can't get the control id. Only you can get the line number causing the error from ex.StackTrace.

From that line you can go and check your code.