locked
The property 'ID' was not found in the object data type in MVP Pattern code RRS feed

  • Question

  • User-1893379617 posted

    Hi,

    I have one requirement . I am working on ASP.NET with MVP pattern projects. There is one gridview with delete button funtionality is there inside gridview. My question is after deleting record from gridview, its calling gridview deleted method and there its throughing error as "The property 'ID' was not found in the object data type" . I have tried with lots of code changes. But still not able to fix this issue . Please remember its completely used MVP Pattern. please see my code in below-

    ASPX Code-
    --------------------
    <asp:GridView ID="grvl"  runat="server" AutoGenerateColumns="False" DataSourceID="ocdsLB" DataKeyNames="ID" CaptionAlign="Left" AllowPaging="True" AllowSorting="True" Width="100%" OnRowDataBound="grvl_OnRowDataBound"  OnRowCommand="grvl_RowCommand" OnRowDeleted="grvl_RowDeleted" OnRowDeleting="grvl_RowDeleting" >
                <Columns>
                    <asp:BoundField DataField="Id" SortExpression="ID" Visible="False" />
                    <asp:BoundField DataField="LBTypeId" SortExpression="LBTypeID" Visible="False" />
                    <asp:BoundField DataField="Name" HeaderText="[LB]" SortExpression="Name" />
                    <asp:BoundField DataField="LBTemplate" HeaderText="LB Template" />
                    <asp:BoundField DataField="Releaser" HeaderText="[Releaser]" SortExpression="Releaser" />
                    <asp:BoundField DataField="Released" HeaderText="[Released]" SortExpression="Released" />
                    <asp:TemplateField HeaderText="[Edit]">
                       
                    </asp:TemplateField>
                      <asp:TemplateField HeaderText="[Delete]">
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkCommandDelete" runat="server" CausesValidation="False" Text="lnkDelete"></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Info">
                   
                </asp:TemplateField> 
                </Columns>
            </asp:GridView>
    
    ------------------------------------------------------------------------------------------------

    Tuesday, December 6, 2016 7:00 PM

Answers

  • User465171450 posted

    You have two different cases for the grid definition for ID.  DataField="Id" SortExpression="ID"

    My guess is ID is incorrect and the SortExpression should be Id and the DataKeyNames should be Id as well.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 7, 2016 6:06 AM

All replies

  • User465171450 posted

    You have two different cases for the grid definition for ID.  DataField="Id" SortExpression="ID"

    My guess is ID is incorrect and the SortExpression should be Id and the DataKeyNames should be Id as well.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 7, 2016 6:06 AM
  • User-707554951 posted

    Hi kamalsekhar,

    From your error message, it indicate that the property “ID” not exist in the object data type,

    After I check your code carefully, I didn’t find any information about “ID” in .cs file,

    So, firstly, I suggest you could set breakpoint to find the error occurred in where.

    Besides, in the following code, it seems that you set wrong filed name, please to check.

    <asp:BoundField DataField="Id" SortExpression="ID" Visible="False" />
    

    Best regards

    Cathy

    Wednesday, December 7, 2016 6:30 AM
  • User-1893379617 posted

    Thank You so much. Its working now

    Wednesday, December 7, 2016 2:45 PM