<%@ Register TagPrefix="DNL" Assembly="DbNetLink.DbNetSuiteVS" Namespace="DbNetLink.DbNetSuiteVS" %>
<DNL:DbNetGrid ID="DbNetGrid1" runat="server" ConnectionString="SamplesDatabaseVistaDB" FromPart="Products Join Suppliers on Products.SupplierID = Suppliers.SupplierID" Update="true" OnBeforeRecordInsert="ValidateInsert" > <Columns> <DNL:GridColumn ColumnExpression="Products.ProductName" Required="true" /> <DNL:GridColumn ColumnExpression="Suppliers.CompanyName" Required="true" /> <DNL:GridColumn ColumnExpression="Suppliers.Country" Required="true" /> <DNL:GridColumn ColumnExpression="Products.UnitPrice" Required="true" Edit="true" /> <DNL:GridColumn ColumnExpression="Products.SupplierID" Display="false" Required="true" Lookup="select SupplierID, CompanyName from Suppliers" /> <DNL:GridColumn ColumnExpression="Products.ProductID" Display="false" Edit="false" /> </Columns> </DNL:DbNetGrid>
/////////////////////////////////////////////////////////////// public bool ValidateInsert(object sender, RecordInsertEventArgs eventArgs) /////////////////////////////////////////////////////////////// { ListDictionary Params = new ListDictionary(); Params["supplierID"] = eventArgs.Record["SupplierID"]; eventArgs.Database.ExecuteSingletonQuery("select country from suppliers where supplierid = @supplierid", Params); if ( eventArgs.Database.Reader["country"].ToString() == "France" ) { eventArgs.Message = "We currenntly are not accepting new products from France."; return false; } else { return true; } }