This is a migrated thread and some comments may be shown as answers.

delete passing empty object

4 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Judith
Top achievements
Rank 1
Judith asked on 14 Jan 2009, 05:41 PM
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

 

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 Jan 2009, 05:48 AM
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.
0
Judith
Top achievements
Rank 1
answered on 15 Jan 2009, 03:51 PM
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
0
Daniel
Top achievements
Rank 1
answered on 31 Mar 2011, 09:40 PM
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
0
Mike
Top achievements
Rank 1
answered on 11 Dec 2017, 09:59 PM
I am having the same issue.  Click Delete.  Empty Object.  Click Update . . . Correct Object
Tags
Grid
Asked by
Judith
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Judith
Top achievements
Rank 1
Daniel
Top achievements
Rank 1
Mike
Top achievements
Rank 1
Share this question
or