Forms Data Controls :: How To Repopulate Insertitemfields When Detailsview Insert Fails Sql Business Logic

Feb 7, 2011

After hitting the insert button the insert stored proc is run. if the record already exists then stored proc returns a specific value.I need to refill the details view textboxes with the values the user typed in.I am using the ItemInserted event handler.I seem to reference the control okay but the text doesn't change...even when I replace the command.parameter to just a literal text like "test".

TextBox tNPA = DetailsView1.FindControl("InsertName") as TextBox;
tNPA.Text = command.Parameters[0].Value.ToString();

So what am I missing. I also tried a detailsview1.databind() before and then tried after the above line and still no luck.

View 17 Replies


Similar Messages:

Forms Data Controls :: Retain Values In A FormView When Validations Fails Or The SQL Fails On An Insert?

Oct 6, 2010

To me this should be much easier, but I can't seem to retain the values that are put in the Insert template upon a validation failure or when the sql fails. This will prevent the user from having to retype everything agin in the event of a failure.

As you can see I am using the Sub Insert_Click and not using an insert through the wizard. so the fields are unbound textboxes on the form. There are 2 dropdowns that provide choices for the other fields.

I pasted in the code using the text only option becuase the format was getting messed up. I probably need more background on why the fields are blanking out.

[code]....

View 8 Replies

Setting A Default Value -- Presentation Logic Or Business Logic?

Jun 18, 2010

I was wondering if setting a default value for a SelectList is considered to be presentation logic or business logic? For example, if a requirement is that an Employee cannot be saved without a Location, but 99% of the time the location that would be selected is a particular item -- say Atlanta. Because of this, the location SelectList should be defaulted to Atlanta when ever a entry screen for a new employee is displayed. Should I be defaulting the location in the model or in the view-model? One thing I realized is that the unit tests become awkward because in both cases, I'd be forced to test against a location that will always be present in production but I cannot create a unit test with my own test dataunless "Atlanta" was in the set of locations being used in the test.

View 4 Replies

DataSource Controls :: Put Business Logic In Sql Or C#?

May 5, 2010

what's is better?That I put my business logic in the sqls(DataStore) or in the C#.DataSore:

[Code]....

What's faster and better?

View 4 Replies

Forms Data Controls :: DetailsView's ObjectDataSource Update Method Fails?

Jan 15, 2011

I am using a gridview to select a record and control that record using a details view. I am using a class based objectdatasource to link the data for select, update and delete. Sofar the select works but the update fails. Here is my error message:

ObjectDataSource 'odsDetailsView_1' could not find a non-generic method 'UpdateSet' that has parameters: setId, TYPE, iHPlayer, iAPlayer, iHRuns, iARuns, iH8Break, iA8Break, iHe8s8, iAe8s8, iH15BRn, iA15BRn, iHWins, iAWins, SET_ID, MATCH_FK, HOME_MEMBER_ID_FK, AWAY_MEMBER_ID_FK, HOME_TABLERUN, AWAY_TABLERUN, HOME_8BALLBREAK, AWAY_8BALLBREAK, HOME_E8S8, AWAY_E8S8, HOME_15BRN, AWAY_15BRN, HOME_TOTALWON, AWAY_TOTALWON, HOME_POINTS, AWAY_POINTS, LOCKED, GROUP_FK.

The first group of parameters have lower case letters and they come from my objectdatasources update method parameters. The second group of parameters are all capitalized and they are the fields in my SQL database table (and I don't know how they wound up in the error). This might be a clue.When executing the code my class method never gets the chance to execute because the error pops up before the code gets there.

Here is my objectdatasource:

[Code]....

Here is my detailsview:

[Code]....

Here is my class update method constructor:

[Code]....

View 1 Replies

Forms Data Controls :: DetailsView BoundFields Auto Binding Not Updating Business Object On Update

Feb 18, 2010

I have a DetailsView (DV) control, an ObjectDataSource (ODS) control, and a button on a page. I have 2 classes in the App_Code directory (Customer and CustomerDAO). The DAO class provides static methods for the ODS control and simply hack values in (ie...no real database selects/updates). The Customer class has 2 properties (Id and Name) and a default constructor. The page takes an ID on the querystring and determines if the DV control is in insert or edit mode. If in edit mode, it sets the SelectParameter on the ODS (id field), calls ODS.Select(), and then calls DV.DataBind(). The existing (although fake) customer is loaded and display properly when this happens. I then change the name of the Customer in the DV and click the Button to save the new data.

Everything seems to be wired up correctly as the UpdateMethod that is specified in the ODS control is called and succeeds (even in my real example with my database). The problem is that the BoundFields in the DV control have not been updated with the new values and therefore the existing values are updated in the database and my changes are lost. I have handled the OnUpdating event of the ODS and the values are still the old values. I have also handled the OnItemUpdating event of the DV control and the NewValues IOrderedDictionary still has the old values in it also. In looking at the MSDN article for the UpdateMethod, it states the following:

Parameter Merging
Parameters are added to the UpdateParameters collection from three sources:

From the data-bound control, at run time.
From the UpdateParameters element, declaratively.
From the Updating event handler, programmatically.

I am using the BoundField classes in my DV control so I would have assumed that the first bullet above would have handled the updating of values, but it doesn't appear to work with the way I am doing it. If I set the values explicitly in the OnUpdating event that is fired by the ODS control (the 3rd bullet) the right values are updated (again...even in my real database situation). It seems like my only issue is that the automatic binding that I expect from the DV control isn't working as I would expect it to. Here is the code that I have in my fake example:

[Code]....

View 7 Replies

Forms Data Controls :: Tricky Insert Logic For Dynamically Created Row In GridView?

Oct 20, 2010

I am dynamically generating the Row in GridView and saving the data in database using StringCollection. Instead of using StringCollection i want to pass the data(user entered data) to local variable , eg:

string name = txtFName; and so on. but it wont work for dynamically created rows.

So if you knw how to assign the user provided data in the local variable like above i have show.

The code for inserting the records for dynamic created rows in grid view via StringCollection is below

protected void btnSave_Click(object sender, EventArgs e)
{
int rowIndex = 0;
StringCollection sc = new StringCollection();

[Code]....

View 4 Replies

Forms Data Controls :: DetailsView EmptyDataTemplate After Insert Defaults To Empty Insert Screen

Jan 27, 2010

In my detailsview, I have an emptydatatemplate set up to allow users to enter new records. The code works. However, once the record is inserted, the detailsview defaults to a standard insert screen. I know this will cause confusion for the users. I would prefer the detailsview to either show in edit mode or a read-only mode. I have used detailsview.changemode and detailsview.currentmode in the custom sub created for the add new button of the emptydatatemplate- neither of which do what I was hoping. It would be even better if when there was no data, it defaulted to the insert screen (which seems like that should be an easy, no-brainer way for .net to function) but it doesn't. Or, I don't know how to accomplish it.

I don't want to force the user to click cancel after inserting an item through the emptydatatemplate just to be able to use the detailsview for other records.

View 2 Replies

Forms Data Controls :: Insert DetailsView Dont Show Read-only Data After Insert?

May 7, 2010

I have a problem with DetailsView linked with Database, DetailsView is Insert/Edit enabled, and adding/ediditng data works, however........ when I add a new record (DetailsView in Insert mode) and press INSET instead going to record I have just created in Read-Only Mode it shows me blank form, it looks that the "linking" field is null.

View 3 Replies

Web Forms :: Exceptions From Business Logic Layer Not Caught In Application_Error?

Nov 11, 2010

I know there are a few posts on this issue already, however I haven't found the answers I was really looking for.

My situation is like this: I have a DLL project containing my business logic. Then I have a web application that refers to this DLL, and calls a function from it. And I have a global.asax which handles errors on Application_Error

Sample:

// MyWebsite.aspx.cs
using MyBusinessLogic;
protected void Page_Load(object sender, EventArgs e)
{
MyBusinessLogicClass.DoSomething();
}
// global.asax.cs
protected void Application_Error(object sender, EventArgs e)

[Code].....

View 6 Replies

MVC :: How To Use Business Logic

Nov 21, 2010

I've got a C# MVC 2 application using EF 4. My DAL project gets data from the Model, translates them into POCO's and returns ViewModels to the BLL which is called from the controllers.I've set up validation attributes on the POCO classes and that works for "Required" fields etc. I would like to add business logic such as "From" has to be before the "To" date. Can this be done on the POCO classes so it is automatically validated client-side in the view?

Also, I would like to add some functionality to the BLL layer such as checking if a resource is already booked between the From and To dates to avoid double bookings. This should fire before the ViewModel is saved. I tried a Try/Catch statement in the controller so that I can throw an error in the BLL, but I don't understand how to return this error to the view with an appropriate error message added.

View 2 Replies

Forms Data Controls :: Dropdownlist In A Formview - Insert Fails Because Of Null Values?

Jan 5, 2010

I have a formview on a web page, set to insert mode as default. The form view is bound to a SQLDatasource. This datasource has a custom query written to select the details for this formview. The query joins two tables to provide relevant detail and not just an ID for one of the elements on the form view.

The first tabe contains information regarding projects and the second table contains detail regarding Resources. First table has the following definition:

[Code]....

View 10 Replies

Web Forms :: Disable View State / No Business Logic In The Button Click Event?

Apr 19, 2010

I have a textbox control i disabled view state at page and control level.i entered a value in the text box and click a button there is a postback,no business logic in the button click event.The values in the testbox are persisting though i disabled at the control level and page level.

View 5 Replies

Where To Write Database And Business Logic In MVC

Sep 9, 2010

As I am learning and working on Asp.Net MVC application, I want to know that what is the better place to write Business Logic and Data Access logic in MVC.Where should I write DataAccess and Business Logic among three layers (Model, View and Controller) ??Could anybody please tell me the correct way to write the code for this.Scenario: I want to retrieve all the employees where employee name like 'Mi%' ( I have SQL procedure to execute and retrieve the data.)PS: Want to know that where I should create instance of Business Logic class and where I should create instance of Data Access layers class?

View 3 Replies

Mvc Linq 2 SQL Model : Where Is The Business Logic

Sep 16, 2010

I'm building a first MVC app in ASP.NET and I'm using link2SQL model to work with data.All tutorials on the microsoft site let you write LINQ code in the controller to get data and pass it to the view, like this:

Function Index() As ActionResult
Dim datacontext As New ErrorVaultDataContext
Dim questions = From q In datacontext.Questions

[code]...

View 3 Replies

Business Logic Not Exposed On Formview

Oct 16, 2010

I have to maintain an ASP.net application in VB.Net. There is a page with a FormView bound to a ObjectDataSource. I have to add some business logic on the ItemUpdating event of this FormView. Unfortunately, some the data that I need to add this business logic is not exposed on the FormView user-interface itself, so I can not use FindControl to get the values (I could add the controls, bind them to the fields I need and set their visible property to true, but that's ugly).

So, what I would need to do is to get access to the Data Row corresponding to the currently selected item in the FormView from the code behind as it has the data I need to add my business logic code. Unfortunately, I don't manage to get access to the row.

View 2 Replies

Business Logic In Stored Procedures?

Mar 8, 2011

Suppose you have to query a lot of tables and calculate some values and spit it out to the user. Is it ok to have all the business logic for this in the stored procedures? Or is it a better practice to return all the data to the application and do all the data manipulation and rolling up in there?

View 6 Replies

C# - Protecting Business Logic In Webservices?

May 8, 2010

Is there a way that a hacker or someone who wants to copy my software logic, can reverse engineer the business logic that I have in a webservice?

Is there a way to protect such information?

My development platform in .net asp.net and C#

View 3 Replies

Implement Transaction In Business Logic Layer?

Jan 17, 2011

I'am using enterprise library data access block in my asp.net application. I want to implement transaction from the Business logic layer, across multiple stored procs. Entlib opens a new connection for database access. Does using Transaction Scope in the following way lead to distributed transaction?

using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
{
// calling necessary DAL methods
scope.Complete();
}

Is there better methods to implement transaction from BLL?

View 1 Replies

Access A Flag Set In Sql Server Into Business Logic?

Jan 4, 2011

public int InsertCompanyDetailsInformation(int companyId, int bankId, int accountNo, string accountType)
{
int rowsAffected = -1;
int returnValue;
try
{
SqlConnection con = DBProvider.GetDbConnection();
using (con)
{
con.Open();
SqlCommand objCmd = new SqlCommand("dbo.sp_InsertCompanyDetailsInformation", con);
objCmd.CommandType = CommandType.StoredProcedure;
objCmd.Parameters.AddWithValue("@companyId", companyId);
objCmd.Parameters.AddWithValue("@bankId", bankId);
objCmd.Parameters.AddWithValue("@accountNo", accountNo);
objCmd.Parameters.AddWithValue("@accountType", accountType);
rowsAffected = objCmd.ExecuteNonQuery();
SqlParameter sqlParam = objCmd.Parameters.Add("@insert_flag", SqlDbType.Int);
objCmd.Parameters["@insert_flag"].Direction = ParameterDirection.ReturnValue;
returnValue = int.Parse(objCmd.Parameters["@insert_flag"].Value.ToString());
con.Close();
}
}
catch (Exception ex)
{
throw ex;
}
return rowsAffected;
}
and stored procedure
USE [SGTime_Development]
GO
/****** Object: StoredProcedure [dbo].[sp_InsertCompanyDetailsInformation] Script Date: 01/04/2011 14:31:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_InsertCompanyDetailsInformation]
(
@companyId int,
@bankId int,
@accountNo int,
@accountType varchar(50))
AS
BEGIN
SET NOCOUNT ON;
declare @insert_flag int;
if not exists(select AccountNo from [Company_Account_Details] where
AccountNo=@accountNo)
begin
INSERT INTO [Company_Account_Details]
( Company_Id,
BankID,
AccountNo,
AccountType)
values
(@companyId,
@bankId,
@accountNo,
@accountType)
set @insert_flag=1;
END
else
begin
set @insert_flag=-1;
end
return @insert_flag;
end

I am getting error in the code i want return returnValue in InsertCompanyDetailsInformation. how we can return returnValue

View 4 Replies

Architecture :: Data Access Layer And Business Logic Layer?

Jun 24, 2010

I am building a web site following the tutorials on asp.net. I am using dataset as data access lay, and writing classes to access the dataset. But the example is just basic ideas, how do I retrieve individual table column value in the business layer?For example, if I have a table called Product, I only want to find out what is the product name by product id. I did this in my ProductBLL:

public ProductBLL
{
public int GetProductName(string productId)
{
ProductDataSet.ProductDataTable prodData = Adapter.GetProductById(productId);
[code]...

Is there a better way, or am I doing this correctly? Can anybody give me a reference to a more complicated business logic model?

View 16 Replies

How To Separate Business Logic And Database Calls From A WCF Web Service

Jun 3, 2010

This question may have been asked before, but I'm looking for a different answer than what I've seen.

Our website is in ASP.NET and we use the model-view-presenter pattern to get business logic out of the markup codebehind.

Is there an accepted pattern for web services for getting business logic out of the codebehind? It seems like putting the logic in a 'presenter' is misleading since the calls don't really present anything to the user, and may not even send back data to the client.

View 1 Replies

MVC :: Calling Business Logic In Model From Submit Tag In View?

Jun 30, 2010

Currently I am working on a project at work that deals with MVC. I have never used MVC before, only dealt a little with ASP with VB, and that's it. I've dabbled in HTML but not much. I don't currently have the money for a book, so I'm using this forum. So there's a lot of jargon I may not pick up on or may ask a lot of questions, so please bare with me.Anyways here's what I would like to do, or understand. We're using ASP.NET Membership Security (not sure if that's what it's actually called) for passwords and accounts. My issue is that I've been working on other projects while the rest of my team has been working on this, so they know more about it than I do. And I don't want to take too long to understand it, but I have to find the best way to make sure the following doesn't happen:

1) When changing a password, it can't be within the last 10 passwords used for that user.2) When creating/changing a password, it cannot have dictionary words, names, phone numbers or personal data within it.3) The password must be a minimum of 16 characters.Number 3 is rather easy and completed I believe. However, 1 and 2 prove tenuous. We want to store the previous passwords hashed and we were going to save the salt used. However, I'm beginning to think that with the Membership class you can't specify the salt to hash a password. Is there a way to de-hash a password? We do not want to store the passwords as plaintext, so that is out of the question.I believe the best order (for 1 and 2) is to do 2 first (before it's hashed) and then 1. For two, I need to know how to call a function in the Model code from a <submit> tag in the View code. I've done a little research online but thought I'd ask and see if it gets answered while I'm looking for the answer.

In general, my questions are:1) How do I call a function in the ****Model.cs from a <submit> tag in the *******.aspx?2) What's the best way to compare previous passwords that are hashed? 3) If I know the salt, can I de-hash a password? (I believe the answer to this is no.)4) Can I specify the salt to hash a password? (I believe the answer to this is no.)5) If #3 and #4 are no, then should I do encryption instead of hashing?Details: MVC2, C#, Membership.

View: Account/ChangePassword.aspx

[Code]....

Model: AccountModel.cs

View 16 Replies

Classic ASP App Has COM 'middle Layer' For Light Business Logic?

Oct 19, 2010

I am trying to estimate how long it will take to migrate a Classic ASP application to .NET and came across hundreds of COM functions written in VB 6.

A majority of these functions only do parameter validation and actually calls the SQL server. Is this something that should be replace with an ORM? (Linq, nHibernate, Entity Framework)... or should there be more to this picture?

View 1 Replies

MVC :: Using EDMX And A 'business Logic' Class To Form The Model?

Jun 4, 2010

This not an 'MVC' question per se, but this is the closest forum I could find. I am building web/wpf/silverlight front end on the MVP pattern. I am using EDMX and a 'business logic' class to form the model, a presenter project, and a view project.The IViews contain the basic structure of each entity, the presenter contains actions, etc.Sample view:

[Code]....

Sample presenter:

[Code]....

QUESTIONS:I seem to end up with a 1-1 mapping of views and presenters. SHould there be more than one view per presenter, or more than one presenter per view? Should the presenter for an entity (in this case a User) also contain methods for functional items such as searching for a filtered list of Users using overloaded methods, etc.?Should the IViewXYZ interface contain any events or actions (methods)?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved