I am having some problems deleting content from my database using the radgrid. In my database, I have a table of "contents", one of "users" and one of "favourites" where there is the pair of user and content ids. I am creating a grid of the user's favourite contents, and want to have a column where he can remove a content from his list of favourites, but not delete the content itself from the contents table in the database.
I tried using the automatic delete of the radgrid, but the problem is that it deletes the actual content from the table "contents", whilst all I want is to remove the pair from the table "favourites". I understand that this is because the datasource is a select to that table "contents", but I am unsure of how I can solve this problem so that the content itself is not deleted but only the favourite.
Here is my code:
<telerik:RadGrid ID="MeusFavoritos" runat="server" AllowPaging="True" AllowSorting="True" DataSourceID="GET_MEUS_FAVORITOS" GridLines="None" AutoGenerateColumns="False" PageSize="5" ClientSettings-EnableRowHoverStyle="True" PagerStyle-Mode="NumericPages" PagerStyle-ShowPagerText="false" >
<MasterTableView CellSpacing="-1" DataSourceID="GET_MEUS_FAVORITOS">
<Columns>
<telerik:GridHyperLinkColumn DataNavigateUrlFormatString="/lms_bd/FichaConteudo.aspx?conteudo={0}" DataTextField="Titulo" Target="_self" DataNavigateUrlFields="IDConteudo" UniqueName="Titulo" HeaderText="Título" SortExpression="Titulo" />
<telerik:GridHyperLinkColumn DataNavigateUrlFormatString="/lms_bd/conteudosTema.aspx?tema={0}" DataTextField="Tema" Target="_self" DataNavigateUrlFields="IDTema" UniqueName="Tema" HeaderText="Tema" SortExpression="Tema" />
<telerik:GridButtonColumn ConfirmText="Tem a certeza que quer remover este conteúdo dos seus favoritos?" ConfirmDialogType="RadWindow"
ConfirmTitle="Remover" ButtonType="ImageButton" CommandName="Delete" Text="Remover"
UniqueName="RemoverFav" ImageUrl="~/imagens/bt_apagar.gif" HeaderText="Remover" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" />
</Columns>
</MasterTableView>
<PagerStyle Mode="NumericPages" ShowPagerText="False" />
<ClientSettings EnableRowHoverStyle="True" />
</telerik:RadGrid>
<asp:SqlDataSource ID="GET_MEUS_FAVORITOS" runat="server" ConnectionString="<%$ ConnectionStrings:lms_bibliotecaConnectionString1 %>"
SelectCommand="SELECT * FROM ([NL_LMS_BIB_conteudos] INNER JOIN NL_LMS_BIB_temas ON NL_LMS_BIB_conteudos.IDTema = NL_LMS_BIB_temas.IDTema)
INNER JOIN NL_LMS_BIB_favoritos on NL_LMS_BIB_conteudos.IDConteudo = NL_LMS_BIB_favoritos.IDConteudo
WHERE NL_LMS_BIB_favoritos.IDUser = @UserID">
<SelectParameters>
<asp:SessionParameter Name="UserID" SessionField="UserID" />
</SelectParameters>
</asp:SqlDataSource>
Can anyone please help me?
Thank you.