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
85
How to delete a row in XamWebgrid from code behind
posted

Hi

I have a delete button in each row and I am trying to delete the row when the user clicks the delete button.Can anybody tell me what property I should use so that I can delete the row from the grid and also the from database.

Thanks

ss

  • 40030
    Offline posted

    Hi, 

    A row has a method called Remove on it. 

    But for your particular sample, you can simply it even more using our Row Delete Command

    <ig:TemplateColumn Key="Delete">

                                  <ig:TemplateColumn.ItemTemplate>

                                        <DataTemplate>

                                              <Button Content="Delete" >

                                                    <igBase:Commanding.Command>

                                                          <ig:XamWebGridRowCommandSource CommandType="Delete" EventName="Click"></ig:XamWebGridRowCommandSource>

                                                    </igBase:Commanding.Command>

                                              </Button>

                                        </DataTemplate>

                                  </ig:TemplateColumn.ItemTemplate>

                            </ig:TemplateColumn>

    And my xmlns definitions look like:

    xmlns:ig="clr-namespace:Infragistics.Silverlight.Controls;assembly=Infragistics.Silverlight.XamWebGrid.v9.1"

    xmlns:igBase="clr-namespace:Infragistics.Silverlight.Controls;assembly=Infragistics.Silverlight.v9.1"

    This will actually update your underlying ItemSource as well.  So, you can track changes there, to pass back to your DB.  Or just use the Grid's RowDeleted event. 

    -SteveZ