linq - ASP.NET Convert Invalid String to Null -


in application have textbox in formview bound linqdatasource so:

<asp:textbox id="mytextbox" runat="server"               text='<%# bind("myvalue") %>' autopostback="true"               ontextchanged="mytextbox_textchanged" />  protected void mytextbox_textchanged(object sender, eventargs e) {     myformview.updateitem(false); } 

this inside updatepanel change field persisted. also, value of myvalue decimal?. works fine unless enter string cannot converted decimal field. in case, updateitem call throws:

linqdatasourcevalidationexception - failed set 1 or more properties on type mytype. asdf not valid value decimal.

i understand problem, asp.net not know how convert 'asdf' decimal?. convert these invalid values null. best way this?

i think should handle updating event of linqdatasource on page. check invalid strings (use tryparse method or something) , continue base class update.

(edit: intuition lines what's recommended here)


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -