Q:

Modify values before inserting through an EntityDataSource Object

I have the following EntityDataSource object:
 <asp:EntityDataSource ID="EntityDataSource1" runat="server"
    ContextTypeName="IntraNET_Prototype.IntraNetEntities" 
    ConnectionString="name=IntraNetEntities" 
    DefaultContainerName="IntraNetEntities" 
    EnableDelete="True" EnableInsert="True" 
    EnableUpdate="True" EntitySetName="EmployeeList" 
    OnInserting="EntityDataSource_Inserting" />

I'm trying to add new data which I added in my gridpanel to my database.
The Problem is when I click the add button in my gridpanel I automatically get a negative value for my primarykey which is simply an id. 
Therefore I'm trying to manipulate the id value from the object which will be inserted by calling the OnInserting="EntityDataSource_Inserting" method.
        protected void EntityDataSource_Inserting(object sender, EntityDataSourceChangingEventArgs e)
    {

    }

My plan was to make a new Dataset Object Reference and set that to the object which will be inserted and then modify the primarykey id here.
Anyway, my attempt to set myDatasetObject newElement = e.Entity did not work as VisualStudio tells me that I'm missing a cast.
How to do that correctly and set that in a right order?
Any Help will be appreciated. 
If you know any better way to set the primarykey (just a continuous figure) (id marker) automatically, let me know!
THANKS

A:

Meanwhile I figured out how to do what I wanted to do, I'm not sure if this is the non plus ultra way to do it, but it WORKS!
        protected void EntityDataSource_Inserting(object sender, EntityDataSourceChangingEventArgs e)
{
myDatasetObject newElement = e.Entity as myDatasetObject;
newElement.id = NextPrimaryID();
}

The ID of the element will be changed as I needed to have it and afterwards it will be saved to the database :-)

