locked
[DetailsView, deleting rows]No value given for one or more required parameters RRS feed

  • Question

  • User-1093321909 posted

    How to delete a row in a simple auto-generated DetailsView showing content of a table? I created auto-generated DetailsView in this way:

    <asp:DetailsView ID="news_table" runat="server" BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" DataSourceID="news_source" AllowPaging="True">

    <Fields>

    <asp:CommandField ShowEditButton="True" EditText="Edytuj" UpdateText="Aktualizuj" CancelText="Anuluj" ShowDeleteButton="True" DeleteText="Usuń nowinkę" NewText="Nowa nowinka" InsertText="Dodaj" ShowInsertButton="True" />

    </Fields>
    </asp:DetailsView>

    <asp:AccessDataSource ID="news_source" runat="server" DataFile="~/App_Data/data.mdb"

    SelectCommand="SELECT pubDate,description_pl,description_en,title_pl,title_en,link_pl,link_en,category_pl,category_en,place,en From news"

    UpdateCommand="UPDATE news Set pubDate=@pubDate,description_pl=@description_pl,description_en=@description_en,title_pl=@title_pl,title_en=@title_en,link_pl=@link_pl,link_en=@link_en,category_pl=@category_pl,category_en=@category_en,place=@place,en=@en" DeleteCommand="DELETE FROM news WHERE description_pl = @description_pl" InsertCommand="INSERT Into news (pubDate,description_pl,description_en,title_pl,title_en,link_pl,link_en,category_pl,category_en,place,en) Values (@pubDate,@description_pl,@description_en,@title_pl,@title_en,@link_pl,@link_en,@category_pl,@category_en,@place,@en)"><DeleteParameters><asp:FormParameter FormField="news_table$ctl02" Name="description_pl"/></DeleteParameters></asp:AccessDataSource>

    After clicking "Usuń nowinkę" (deleting button), the error occurs "System.Data.OleDb.OleDbException: No value given for one or more required parameters". Earlier I tried without parameter, with ControlParameter, with Parameter (Name="description_pl") and this causes the same error. Data is inserted, updated and selected correctly, only deleting causes error. When I used simple DeleteCommand "Delete From news", whole content of the table was being deleted. Could you help me? I am asking for help politely.

    Tuesday, July 10, 2007 10:25 AM

Answers

  • User-1995538749 posted

    Use the standard Parameter control with the name set to 'description_pl'. Then, add this same field name to the DetailsView.DataKeyNames property declaratively within your ASPX. Hopefully this should solve your problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 10, 2007 10:41 AM

All replies

  • User-1995538749 posted

    Use the standard Parameter control with the name set to 'description_pl'. Then, add this same field name to the DetailsView.DataKeyNames property declaratively within your ASPX. Hopefully this should solve your problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 10, 2007 10:41 AM
  • User-1093321909 posted

    Thank you. I inserted 'DataKeyNames="description_pl"' to DetailsView.

    Tuesday, July 10, 2007 11:37 AM