Last post Apr 08, 2011 11:33 PM by Decker Dong - MSFT
Apr 06, 2011 11:29 AM|fakepoo|LINK
I have an ObjectDataSource that is configured to use my data access layer class. The select method returns a DataTable. The DeleteMethod takes a System.Guid as a parameter. I am using a FormView object on my page that shows information from the Row of the
table and allows paging. In the FormView, I also have a "delete" button with the CommandName attribute set to "Delete".
Without setting anything up, clicking the delete button would send an empty Guid to my delete method. So, I thought it was because my DataKeyNames property of the FormView was empty. So, I set the DataKeyNames property to "SystemId" which is the value from
the DataRow of the current item that I would like to use as the primary key. This caused all sorts of problems basically saying that DataObjectTypeName of the the ObjectDataSource did not have a property called "SystemId". I tried adding a DeleteParameters
section to the ObjectDataSource and specifying one but had no success.
Obviously, I'm missing a simple step here but I have not been able to figure it out. Below is the markup:
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
There are no pictures currently associated with this site.
<h3><%# Eval("Description") %></h3>
<img src="<%# Eval("Path") %>" alt="<%# Eval("Description") %>"/>
<asp:Button ID="DeleteButton" runat="server" Text="Delete" CommandName="Delete" />
The class definition looks like this:
public DataTable GetPictures()
public void DeletePicture(Guid SystemId)
Any help is appreciated.
Apr 08, 2011 11:33 PM|Decker Dong - MSFT|LINK
Where did you add your DeleteParameters? I couldn't see in your aspx markups. So I suggest you trying the way:)
Try to add the DeleteParameters——
<asp:parameter name="anID" type="Object" />