I am trying to create a button where I can delete something from a table in my database.
I need to know the contentID of the item that was clicked so that I can use it as a parameter (@idconteudo) in my delete statement.
The column in question in called "Remover".
Here is my grid:
<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>
My radgrid is populated by this datasource, and the problem I am having is with the delete part. I don't understand how to use the id of the content clicked for my where clause in the delete. The datasource is:
<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" DeleteCommand="DELETE FROM [NL_LMS_BIB_favoritos] WHERE IDUser = @UserID AND IDConteudo = @idconteudo" >
<SelectParameters>
<asp:SessionParameter Name="UserID" SessionField="UserID" />
</SelectParameters>
<DeleteParameters>
<asp:SessionParameter Name="UserID" SessionField="UserID" />
<asp:Parameter Name="idconteudo" />
</DeleteParameters>
</asp:SqlDataSource>
Can anyone please help?
Thank you.