c# - Error validaing new data while updating gridview row data in asp.net web form? -


i'm creating simple web forms application using asp.net registering patients data using entity framework.i'm using dynamic data fields easy validation of editable data based on microsoft sql server data types , null allow

data table

my aspx code entity data source , data gridview

<asp:entitydatasource id="entitydatasource1" runat="server" contexttypename="webapplication4.pediatricdbentities" enabledelete="true" enableflattening="false" enableinsert="true" enableupdate="true" entitysetname="patients" entitytypefilter="patient">     </asp:entitydatasource>     <br />     <asp:gridview id="gridview1" runat="server" allowpaging="true" allowsorting="true" autogeneratecolumns="false" datakeynames="patientid" datasourceid="entitydatasource1">         <columns>             <asp:commandfield showdeletebutton="true" showeditbutton="true" showselectbutton="true" />             <asp:dynamicfield datafield="patientid" headertext="patientid" readonly="true" sortexpression="patientid" />             <asp:dynamicfield datafield="name" headertext="name" sortexpression="name" />             <asp:dynamicfield datafield="birthdate" headertext="birthdate" sortexpression="birthdate" />             <asp:dynamicfield datafield="sex" headertext="sex" sortexpression="sex" />             <asp:dynamicfield datafield="location" headertext="location" sortexpression="location" />             <asp:dynamicfield datafield="phone" headertext="phone" sortexpression="phone" />         </columns>     </asp:gridview>     <asp:validationsummary id="validationsummary1" runat="server" /> 

cs code behind

protected void page_init(object sender, eventargs e)     {         gridview1.enabledynamicdata(typeof(patient));     } 

however when try edit data , set field not allows null null value error appear before validation summary appears follows enter image description here

i want know how validate new data while updating data grid view row using dynamic fields .

this can done setting metadatatypes against objects.

as example name field..

  [metadatatype(typeof(patientmetadata))]   public partial class patient   {     public class patientmetadata     {       [required]       public string name { get; set; }        ....      }   } 

a walkthrough available here:

http://msdn.microsoft.com/en-us/library/cc488549(vs.100).aspx


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -