Hi Sjnaughton,
When I drag the stored procs onto the table in the dbml I get this error: "One or more selected database objects return a schema that does not match the schema of the target class".
In attempt to sot this out myself I have added insert and updates methods to my BLL file and have used the actual stored proc for insert. I am using the same ListDetails template for a few pages so in the DetailsViewItemInserting event I find what table is being shown and then call my insert method for that table. I have the code below - how do I get a ContainerCode instance which is what the user has just entered? right now that line is returning a new instance which is null...
VALIDATION AND INSERT CODE in BLL:
// Method for inserting container code
public void InsertContainerCode(ContainerCode instance)
{
//ContainerCode instance = ContainerCode();
var Fcc = new ParentFccOnlineNettingDataContext();
// Check that the following are unique: --------------------------------------------------------------//
// Container Code
var container = Fcc.ContainerCodes.FirstOrDefault(c => c.FCCContainerCode == instance.FCCContainerCode);
//---------------------------------------------------------------------------------------------------//
// If the container code is unique
if (container != null)
{
throw new ValidationException(String.Format("The Container Code {0} already exists. Please specify a different code.", instance.FCCContainerCode));
}
else
{
// finally send this to the DB
int? insertedId = 0;
Fcc.ContainerCode_Insert(ref insertedId, instance.FCCContainerCode, instance.IsActive);
}
}
LISTDETAILS.ASPX.CS:
protected void OnDetailsViewItemInserting(object sender, EventArgs e)
{
string tableName = GridDataSource.TableName;
if (tableName == "ContainerCodes")
{
ContainerCode instance = new ContainerCode();
ContainerCodeBLL container = new ContainerCodeBLL();
container.InsertContainerCode(instance);
}
else if (tableName == "Supplier")
{
}
else if (tableName == "Market")
{
}
}
Appreciate some help.
Cheers.
Mel