HELP !!! ObjectDataSource Delete Parameter Problem ASP.NET 2.0

  • Thread starter Thread starter Microsoft news
  • Start date Start date
M

Microsoft news

Hi,

I have a problem with delete method:

public static int DeleteEmployee(string original_EmployeeId)

{

return ClassDB.DeleteEmployee(original_EmployeeId);

}



And in aspx :

<asp:ObjectDataSource ID="ObjectDataSource1" Runat="server"
DeleteMethod="DeleteEmployee" TypeName="BusinessObject"
SortParameterName="sortExpression" ></asp:ObjectDataSource>

Any advice please I have a pb to pass parameter !!!!

I tried also with <DeleteParameter> ... the same pb



Thanks

Tarek.
 
Hi again,

I solved the problem , I added the DataKeyNames for the GridView and this is
logical because when you need to delete something you should use the primary
key (by mistake DataKeyNames not defined), and i used the same code but
attention for (original_)

public static int DeleteEmployee(string original_EmployeeId)
{
return ClassDB.DeleteEmployee(original_EmployeeId);
}

And in aspx :
<asp:GridView ............ DataKeyNames="EmployeeId" >.....</asp:GridView>

<asp:ObjectDataSource ID="ObjectDataSource1" Runat="server"
DeleteMethod="DeleteEmployee" TypeName="BusinessObject"
SortParameterName="sortExpression" ></asp:ObjectDataSource>

Thanks,

Tarek
 
Back
Top