无法删除 GridView 中的行,为什么?

发布于 2024-10-31 08:48:39 字数 2268 浏览 0 评论 0原文

早上好, 拜托,我有依赖的 GridView,我想删除行,但它不起作用。 问题:方法“SmazOrdinacniDobu”(用于删除)具有参数 OrdinacniDoba 类型,但该参数为空...为什么? :( (但是更新工作正常......)

<asp:ObjectDataSource ID="odsOrdinacniHodiny" runat="server" 
    DataObjectTypeName="Praktik.DB.OrdinacniDoby.OrdinacniDoba" 
    DeleteMethod="SmazOrdinacniDobu" InsertMethod="VytvorNovou" 
    SelectMethod="VratVseOrdinaci" 
    TypeName="Praktik.DB.OrdinacniDoby.OrdinacniDoby" 
    UpdateMethod="UpravOrdinacniDobu">
<SelectParameters>
    <asp:ControlParameter ControlID="gwOrdinace" DefaultValue="0" Name="id" 
        PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:GridView ID="gwOrdinacniDoba" runat="server" AutoGenerateColumns="False" 
    EnableModelValidation="True" 
    onrowupdating="gwOrdinacniDoba_RowUpdating" 
    DataSourceID="odsOrdinacniHodiny" AutoGenerateDeleteButton="True" 
    EnableViewState="False">
<Columns>
    <asp:CommandField ButtonType="Image" 
        CancelImageUrl="~/App_Themes/ZdravotnickaZarizeni/design/cancel.png" 
        EditImageUrl="~/App_Themes/ZdravotnickaZarizeni/design/pencil.png" 
        ShowEditButton="True" 
        UpdateImageUrl="~/App_Themes/ZdravotnickaZarizeni/design/check.png" />
    <asp:BoundField DataField="IDOrdinacniDoby" HeaderText="ID Ordinační doby" />
    <asp:BoundField DataField="IDOrdinace" HeaderText="ID Ordinace" />
    <asp:BoundField DataField="PlatnostOd" HeaderText="Platnost od data" DataFormatString="{0:D}" />
    <asp:BoundField DataField="PlatnostDo" HeaderText="Platnost do data" DataFormatString="{0:D}" />
    <asp:BoundField DataField="Den" HeaderText="Den v týdnu" />
    <asp:BoundField DataField="RezervaceOd" HeaderText="Rezervace od" />
    <asp:BoundField DataField="RezervaceDo" HeaderText="Rezervace do" />
    <asp:BoundField DataField="OpakovatPoTydnech" HeaderText="Opakovat po týdnech" />
    <asp:CheckBoxField DataField="Pritomen" HeaderText="Přítomen?" />
    <asp:CommandField ButtonType="Image" 
        DeleteImageUrl="~/App_Themes/ZdravotnickaZarizeni/design/non.png" 
        ShowDeleteButton="True" />
</Columns>
</asp:GridView>

Good morning,
please, I have dependent GridView and I want delete row, but it not working.
Problem: method 'SmazOrdinacniDobu' (for deleting) have type of parameter OrdinacniDoba, but this parameter is empty... Why? :(
(But update working fine...)

<asp:ObjectDataSource ID="odsOrdinacniHodiny" runat="server" 
    DataObjectTypeName="Praktik.DB.OrdinacniDoby.OrdinacniDoba" 
    DeleteMethod="SmazOrdinacniDobu" InsertMethod="VytvorNovou" 
    SelectMethod="VratVseOrdinaci" 
    TypeName="Praktik.DB.OrdinacniDoby.OrdinacniDoby" 
    UpdateMethod="UpravOrdinacniDobu">
<SelectParameters>
    <asp:ControlParameter ControlID="gwOrdinace" DefaultValue="0" Name="id" 
        PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:GridView ID="gwOrdinacniDoba" runat="server" AutoGenerateColumns="False" 
    EnableModelValidation="True" 
    onrowupdating="gwOrdinacniDoba_RowUpdating" 
    DataSourceID="odsOrdinacniHodiny" AutoGenerateDeleteButton="True" 
    EnableViewState="False">
<Columns>
    <asp:CommandField ButtonType="Image" 
        CancelImageUrl="~/App_Themes/ZdravotnickaZarizeni/design/cancel.png" 
        EditImageUrl="~/App_Themes/ZdravotnickaZarizeni/design/pencil.png" 
        ShowEditButton="True" 
        UpdateImageUrl="~/App_Themes/ZdravotnickaZarizeni/design/check.png" />
    <asp:BoundField DataField="IDOrdinacniDoby" HeaderText="ID Ordinační doby" />
    <asp:BoundField DataField="IDOrdinace" HeaderText="ID Ordinace" />
    <asp:BoundField DataField="PlatnostOd" HeaderText="Platnost od data" DataFormatString="{0:D}" />
    <asp:BoundField DataField="PlatnostDo" HeaderText="Platnost do data" DataFormatString="{0:D}" />
    <asp:BoundField DataField="Den" HeaderText="Den v týdnu" />
    <asp:BoundField DataField="RezervaceOd" HeaderText="Rezervace od" />
    <asp:BoundField DataField="RezervaceDo" HeaderText="Rezervace do" />
    <asp:BoundField DataField="OpakovatPoTydnech" HeaderText="Opakovat po týdnech" />
    <asp:CheckBoxField DataField="Pritomen" HeaderText="Přítomen?" />
    <asp:CommandField ButtonType="Image" 
        DeleteImageUrl="~/App_Themes/ZdravotnickaZarizeni/design/non.png" 
        ShowDeleteButton="True" />
</Columns>
</asp:GridView>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

德意的啸 2024-11-07 08:48:39

使用属性 DatakeyNames 在 gridview 中绑定数据源的主键。在行命令或行删除事件中,找到该键并删除该行。

Bind the primary key of your datasource in the gridview with attribute DatakeyNames. In row command or row deleting event, find that key and delete the row.

嗳卜坏 2024-11-07 08:48:39

首先,您还没有向 gridview 提供 DataKeyNames 。其次,您没有提供删除方法参数

 <DeleteParameters>
     <asp:Parameter Name="ParameterName" Type="Int32" />
 </DeleteParameters>

First of all you have not provided DataKeyNames to your gridview. Secondly you have not provided Delete method parameter

 <DeleteParameters>
     <asp:Parameter Name="ParameterName" Type="Int32" />
 </DeleteParameters>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文