Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
445
update rows in webdatagrid
posted

Hello,

I have really some problems using the webdatagrid in order to make simple CRUD with a database.

I have my grid with some data and outside of my grid, I have "new row" button, "edit" button, "delete" button and "save" and "cancel" button.

The "add new" and "delete" row are now managed, but I have lot of difficulties with edit.

When I click on edit, all cells in my grid become editable, I could change value I want, but when I click save, I have this error:

Sys.WebForms.PageRequestManagerServerErrorException: Table doesn't have a primary key

But what I want is only make my own treatments (so update in database) taking the value entered in my grid.

In other words, when I click on save, I would like to have my postback, then run some code then go back to my grid, but I could not due to this error.

Just a precision: my grid is binded in code behind, and I do not use SQLDataSources.

Please find the code I used for my web datagrid:

<ig:WebDataGrid ID="GridSpecBottom" runat="server" AutoGenerateColumns="False"
 DataKeyFields="NO_IN_ROW" AjaxIndicator-Enabled="False"
 oninit="GridSpecBottom_Init"
 onrowadding="GridSpecBottom_RowAdding" onrowupdating="GridSpecBottom_RowUpdating" >
 <Columns>
  <ig:BoundDataField DataFieldName="NO_IN_ROW" Key="NO_IN_ROW" Width="40px">
   <Header Text="<%$ Resources:Labels, lblNO_IN_ROW %>" />
  </ig:BoundDataField>
   <ig:BoundDataField DataFieldName="ARTNO" Key="ARTNO" Width="40px">
   <Header Text="<%$ Resources:Labels, lblARTNO %>" />
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="ARTICLENO" Key="ARTICLENO" Width="60px">
   <Header Text="<%$ Resources:Labels, lblARTICLENO %>" />
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="EXTRA1" Key="EXTRA1" Width="100px">
   <Header Text="<%$ Resources:Labels, lblEXTRA1 %>" />
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="DESCRIP" Key="DESCRIP" Width="250px">
   <Header Text="<%$ Resources:Labels, lblDESCRIP %>" />
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="POSITION" Key="POSITION" Width="140px">
   <Header Text="<%$ Resources:Labels, lblPOSITION %>" />
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="QUANTITY" Key="QUANTITY" Width="40px">
   <Header Text="<%$ Resources:Labels, lblQUANTITY %>" />
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="EXTRA2" Key="EXTRA2" Width="40px">
   <Header Text="<%$ Resources:Labels, lblEXTRA2 %>" />
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="FIELD1" Key="FIELD1" Width="80px">
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="FIELD2" Key="FIELD2" Width="80px">
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="FIELD3" Key="FIELD3" Width="80px">
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="FIELD4" Key="FIELD4" Width="80px">
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="FIELD5" Key="FIELD5" Width="80px">
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="FIELD6" Key="FIELD6" Width="80px">
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="FIELD7" Key="FIELD7" Width="80px">
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="FIELD8" Key="FIELD8" Width="80px">
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="FIELD9" Key="FIELD9" Width="80px">
  </ig:BoundDataField>
  <ig:BoundDataField DataFieldName="FIELD10" Key="FIELD10" Width="80px">
  </ig:BoundDataField>
 </Columns>
 <Behaviors>
  <ig:EditingCore>
   <Behaviors>
    <ig:RowAdding Alignment="Top">
     <ColumnSettings>
      <ig:RowAddingColumnSetting ColumnKey="NO_IN_ROW" ReadOnly="true" />
      <ig:RowAddingColumnSetting ColumnKey="ARTNO" EditorID="DDLArtno" />
      <ig:RowAddingColumnSetting ColumnKey="EXTRA2" EditorID="DDLUnit" />
     </ColumnSettings>
     <EditModeActions MouseClick="Single" />
    </ig:RowAdding>
    <ig:RowDeleting Enabled="true" />
    <ig:CellEditing Enabled = "false">
     <ColumnSettings>
      <ig:EditingColumnSetting ColumnKey="NO_IN_ROW" ReadOnly="true" />
      <ig:EditingColumnSetting ColumnKey="ARTNO" EditorID="DDLArtno" />
      <ig:EditingColumnSetting ColumnKey="EXTRA2" EditorID="DDLUnit" />
     </ColumnSettings>
     <EditModeActions MouseClick="Single" />
    </ig:CellEditing>
   </Behaviors>
  </ig:EditingCore>
  <ig:Selection CellClickAction="Row" RowSelectType="Single">
  </ig:Selection>
  <ig:RowSelectors>
  </ig:RowSelectors>
 </Behaviors>
 <EditorProviders>
  <ig:DropDownProvider ID="DDLArtno">
   <EditorControl runat="server" DisplayMode="DropDownList" DropDownContainerHeight="100px"
     DropDownContainerWidth="100px"   DataKeyFields="ARTNO">
    <DropDownItemBinding  TextField="YAR" ValueField="YAR"/>
     <Items>
      <ig:DropDownItem Selected="False" Text="YAR" Value="YAR">
      </ig:DropDownItem>
      <ig:DropDownItem Selected="False" Text="BRA" Value="BRA">
      </ig:DropDownItem>
      <ig:DropDownItem Selected="False" Text="LIN" Value="LIN">
      </ig:DropDownItem>
      <ig:DropDownItem Selected="False" Text="BUT" Value="BUT">
      </ig:DropDownItem>
     </Items>
   </EditorControl>
  </ig:DropDownProvider>
  <ig:DropDownProvider ID="DDLUnit">
   <EditorControl runat="server" DisplayMode="DropDownList" DropDownContainerHeight="100px"
     DropDownContainerWidth="100px"   DataKeyFields="UNIT">
    <DropDownItemBinding  TextField="M" ValueField="M"/>
     <Items>
      <ig:DropDownItem Selected="False" Text="CM" Value="CM">
      </ig:DropDownItem>
      <ig:DropDownItem Selected="False" Text="PCS" Value="PCS">
      </ig:DropDownItem>
      <ig:DropDownItem Selected="False" Text="YD" Value="YD">
      </ig:DropDownItem>
      <ig:DropDownItem Selected="False" Text="KG" Value="KG">
      </ig:DropDownItem>
     </Items>
   </EditorControl>
  </ig:DropDownProvider>
 </EditorProviders>
</ig:WebDataGrid>

 Thanks for your help

Best Regards

Damien

Parents Reply Children
No Data