delete passing empty object

4 posts, 0 answers
  1. Judith
    Judith avatar
    14 posts
    Member since:
    Aug 2007

    Posted 14 Jan 2009 Link to this post

    I have created a grid using telerik radgrid and I am trying to delete a record using the auto delete built in to the grid. I have set up my dataosourcebject as follows

    <

     

    asp:ObjectDataSource ID="ObjectDataSource2" SelectMethod="GetList" DeleteMethod="Delete"

     

    OldValuesParameterFormatString

     

    ="{0}" DataObjectTypeName = "IngredientSourceBusinessObject.IngredientSource"

     

     

    TypeName="IngredientSourceBusinessObjectManager.IngredientSourceManager" runat="server">

     

    </

     

    asp:ObjectDataSource>

    The source for my grid is as follows


     

    <

     

    telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True"

     

     

    AllowSorting="True"

     

     

    DataSourceID="ObjectDataSource2" DataKeyNames="Id" GridLines="None"

     

     

    Skin="Sunset" AllowAutomaticDeletes="True" AutoGenerateDeleteColumn="True"

     

     

    AutoGenerateColumns="False">

     

    <

     

    HeaderContextMenu EnableTheming="True">

     

    <

     

    CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

     

    </

     

    HeaderContextMenu>

     

     

     

     

     

    <PagerStyle AlwaysVisible="True" Mode="NextPrevAndNumeric" />

     

    <

     

    MasterTableView datasourceid="ObjectDataSource2"

     

     

    overridedatasourcecontrolsorting="True">

     

    <

     

    RowIndicatorColumn>

     

    <

     

    HeaderStyle Width="20px"></HeaderStyle>

     

    </

     

    RowIndicatorColumn>

     

    <

     

    ExpandCollapseColumn>

     

    <

     

    HeaderStyle Width="20px"></HeaderStyle>

     

    </

     

    ExpandCollapseColumn>

     

     

     

     

     

    <Columns>

     

     

     

     

     

    <telerik:GridBoundColumn DataField="EntryDate" DataFormatString="{0:d}"

     

     

    DataType="System.DateTime" HeaderText="Entry Date" UniqueName="column1">

     

     

     

     

     

    </telerik:GridBoundColumn>

     

     

     

     

     

    <telerik:GridBoundColumn DataField="ID" HeaderText="ID" UniqueName="column2">

     

     

     

     

     

    </telerik:GridBoundColumn>

     

     

     

     

     

    <telerik:GridBoundColumn DataField="FullName" HeaderText="Company Name"

     

     

    SortExpression="FullName" UniqueName="column">

     

     

     

     

     

    </telerik:GridBoundColumn>

     

     

     

     

     

    </Columns>

     

     

     

     

     

    <PagerTemplate>

     

     

     

     

     

    <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument="First"

     

     

    CommandName="Page">First</asp:LinkButton>

     

     

     

     

     

    <asp:LinkButton ID="LinkButton3" runat="server"

     

     

    CommandArgument="Prev" CommandName="Page">Prev</asp:LinkButton>

     

     

     

     

     

    <asp:TextBox ID="TxtPageNumber" runat="server"

     

     

    Text='<%# Convert.ToInt32(DataBinder.Eval(Container, "OwnerTableView.CurrentPageIndex")) + 1 %>'

     

     

    style="z-index: 1" Width="48px"></asp:TextBox>

     

     

     

     

     

    <asp:LinkButton ID="LinkButton5" runat="server" CommandName="CustomChangePage">Go</asp:LinkButton>

     

     

     

     

     

    <asp:LinkButton ID="LinkButton4" runat="server"

     

     

    CommandArgument="Next" CommandName="Page">Next</asp:LinkButton>

     

     

     

     

     

    <asp:LinkButton ID="LinkButton2" runat="server" CommandArgument="Last"

     

     

    CommandName="Page">Last</asp:LinkButton>

     

     

     

     

     

    </PagerTemplate>

     

    </

     

    MasterTableView>

     

     

     

     

     

    <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">

     

     

     

     

     

    <selecting allowrowselect="True" />

     

     

     

     

     

    </ClientSettings>

     

    <

     

    FilterMenu EnableTheming="True">

     

    <

     

    CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

     

    </

     

    FilterMenu>

     

    </

     

    telerik:RadGrid>

     

    When i click on the delete link the progam sends an empty object to my business layer.

    I have tried this with a gridview from visual studio 8 and it works fine.

    I am guessing that maybe this problem has to do with binding but I am unclear about that.
    I have enabled sorting on the grid so overridedatasourcecontrolsorting is set to true but I tried it also set to false and that did not work either.
    I would appreciate any help with this
    Thank you
    Judith

     

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 Jan 2009 Link to this post

    Hi Judith,

    Can you try the sample aplication given the code library and check whether it's working for you. The link to code library is given below.
    Automatic operations with ObjectDataSource control

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Judith
    Judith avatar
    14 posts
    Member since:
    Aug 2007

    Posted 15 Jan 2009 Link to this post

    The sample you refer to uses datasets and my application is using business objects. I would like the grid to pass back a business object not individual parameters.   If you set DataObjectTypeName to an object then it should pass back a business object of that type when doing automatic operations. I have gotten this to work with a regular gridview but I would like to get it to work with the Telerik grid. 
    Thanks
    Judith
  5. Daniel
    Daniel avatar
    8 posts
    Member since:
    Mar 2011

    Posted 31 Mar 2011 Link to this post

    I am running into the same problem.  It seems my "insert" is populating the object, but "delete" and "update" are not (completely empty objects).  I am using MVC3 and razor.

    Did the original poster find a solution to their problem?  It's driving me nuts trying to find the difference between calls... why one would pass the data and one won't.

    UPDATE: I defined my ".DataKeys" to specify the ObjectId that uniquely identifies each row (I already had that).  If I bound a column to include the ObjectId, then it does get passed.  However, the ObjectId is a GUID and not something the user should ever see.  I've tried setting this column to hidden(true) or visible(false), but neither seems to help.  Plus, I've never seen an example where you define your grid, define the datakeys, AND put the same datakeys as columns.

    UPDATE:  I've gone line by line of this document trying to find something that wasn't setup properly and I can't seem to find anything.  When I view the HTML of the grid, I don't see where the GUIDs are being outputted at all.  http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-editing-ajax-editing.html

    UPDATE: I've managed to get it to throw this error, which tells me it is getting further than before.  I didn't have any null, empty, or "zeroed" date fields.  Just in case, I deleted everything in the entire table and still get the error.

    Unable to convert MySQL date/time value to System.DateTime


    UPDATE: Here was the solution I came to with my own problem.  I was having success with one grid but problems on another (which both had a DateTime field).  So, I made sure that "not null" was set on my DB table and deleted my DBModel.edmx and regenerated it (built from the DB).  So, I no longer get the DateTime conversion error.  But, of course, I am still having the original problem of empty objects being passed when trying to do an edit/delete, etc.  wtf.

     Thank you,
    Daniel
Back to Top