Hi,
I am trying to write an asp.net page that uses a details view to display customer details and allows customers to update those details by editing the various fields and clicking update.
The problem I am having is that when I click update the select method is being called and not the update method. I have a class where the update and select methods are located. Select is also being called on page load which is fine.
I will post some of the code below. I am using visual web developer express 2008 I can debug the c# code but don't know how to run the debugger on the client side code. Any help appreciated!
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateEditButton="True"
DataSourceID="ObjectDataSource1" DefaultMode="Edit" Height="50px"
Width="617px" AutoGenerateRows="False" BorderColor="WhiteSmoke">
<Fields>
<asp:BoundField DataField="UserId" HeaderText="user id"
NullDisplayText="" />
<asp:BoundField DataField="first_name" HeaderText="first name"
NullDisplayText="" />
<asp:BoundField DataField="last_name" HeaderText="last name" />
<asp:BoundField DataField="company_name" HeaderText="company name" />
<asp:BoundField DataField="business_address_first_line"
HeaderText="first line of business address" />
<asp:BoundField DataField="business_address_second_line"
HeaderText="second line of business address" />
<asp:BoundField DataField="business_address_third_line"
HeaderText="third line of business address" />
<asp:BoundField DataField="business_address_country"
HeaderText="business address country" />
<asp:BoundField DataField="business_city" HeaderText="business address city" />
<asp:BoundField DataField="business_postcode"
HeaderText="business address postcode" />
<asp:BoundField DataField="business_land_line_phone_number"
HeaderText="business address land line phone number" />
<asp:BoundField DataField="business_mobile_phone_number"
HeaderText="business address mobile phone number" />
<asp:BoundField DataField="business_fax_number"
HeaderText="business address fax number" />
<asp:BoundField DataField="delivery_company_name"
HeaderText="delivery company name" />
<asp:BoundField DataField="delivery_address_first_line"
HeaderText="first line of delivery address" />
<asp:BoundField DataField="delivery_address_second_line"
HeaderText="second line of delivery address" />
<asp:BoundField DataField="delivery_address_third_line"
HeaderText="third line of delivery address" />
<asp:BoundField DataField="delivery_address_country"
HeaderText="delivery address country" />
<asp:BoundField DataField="delivery_city" HeaderText="delivery city" />
<asp:BoundField DataField="delivery_postcode" HeaderText="delivery postcode"
NullDisplayText="""" />
<asp:BoundField DataField="delivery_telephone" HeaderText="delivery telephone number"
NullDisplayText="""" />
<asp:BoundField DataField="contact_email_address" HeaderText="contact e-mail address" />
<asp:BoundField DataField="pguk_account_no" HeaderText="PG UK Account No" />
<asp:BoundField DataField="est_turnover" HeaderText="est turnover" />
<asp:BoundField DataField="shipper_name" HeaderText="Shipping Company Name" />
<asp:BoundField DataField="shipper_address_first_line" HeaderText="Shipping Address First Line"/>
<asp:BoundField DataField="shipper_address_second_line" HeaderText="Shipping Address Second Line"/>
<asp:BoundField DataField="shipper_address_third_line" HeaderText="Shipping Address Third Line"/>
<asp:BoundField DataField="shipper_address_city" HeaderText="Shipping Address City"/>
<asp:BoundField DataField="shipper_address_postcode" HeaderText="Shipping Address Postcode"/>
<asp:BoundField DataField="shipper_address_country" HeaderText="Shipping Address Country"/>
<asp:BoundField DataField="shipper_telephone_number" HeaderText="Shipping Telephone Number"/>
<asp:BoundField DataField="shipper_contact_person" HeaderText="Shipping Contact Person"/>
</Fields>
</asp:DetailsView>
<asp:ObjectDataSource ID="ObjectDataSource1"
SelectMethod="SelectTradeCustomers" TypeName="ShoppingCartAccess"
UpdateMethod="UpdateTradeCustomers"
runat="server">
<UpdateParameters>
<asp:SessionParameter Name="UserId" SessionField="UserId" DbType="Guid"/>
<asp:Parameter Name="first_name" Type="String" />
<asp:Parameter Name="last_name" Type="String" />
<asp:Parameter Name="company_name" Type="String" />
<asp:Parameter Name="business_address_first_line" Type="String" />
<asp:Parameter Name="business_address_second_line" Type="String" />
<asp:Parameter Name="business_address_third_line" Type="String" />
<asp:Parameter Name="business_address_country" Type="String" />
<asp:Parameter Name="business_city" Type="String" />
<asp:Parameter Name="business_postcode" Type="String" />
<asp:Parameter Name="business_land_line_phone_number" Type="String" />
<asp:Parameter Name="business_mobile_phone_number" Type="String" />
<asp:Parameter Name="business_fax_number" Type="String" />
<asp:Parameter Name="delivery_company_name" Type="String" />
<asp:Parameter Name="delivery_address_first_line" Type="String" />
<asp:Parameter Name="delivery_address_second_line" Type="String" />
<asp:Parameter Name="delivery_address_third_line" Type="String" />
<asp:Parameter Name="delivery_address_country" Type="String" />
<asp:Parameter Name="delivery_city" Type="String" />
<asp:Parameter Name="delivery_postcode" Type="String" />
<asp:Parameter Name="delivery_telephone" Type="String" />
<asp:Parameter Name="contact_email_address" Type="String" />
<asp:Parameter Name="pguk_account_no" Type="String" />
<asp:Parameter Name="est_turnover" Type="String" />
<asp:Parameter Name="comments" Type="String" />
<asp:Parameter Name="shipper_name" Type="String" />
<asp:Parameter Name="shipper_address_first_line" Type="String" />
<asp:Parameter Name="shipper_address_second_line" Type="String" />
<asp:Parameter Name="shipper_address_third_line" Type="String" />
<asp:Parameter Name="shipper_address_city" Type="String" />
<asp:Parameter Name="shipper_address_postcode" Type="String" />
<asp:Parameter Name="shipper_address_country" Type="String" />
<asp:Parameter Name="shipper_telephone_number" Type="String" />
<asp:Parameter Name="shipper_contact_person" Type="String" />
</UpdateParameters>
<SelectParameters>
<asp:SessionParameter Name="UserId" SessionField="UserId" DbType="Guid" />
</SelectParameters>
</asp:ObjectDataSource>
Below is from ShoppingCartAccessClass
public static bool UpdateTradeCustomers(Object UserId, string first_name, string last_name,
string company_name, string business_address_first_line, string business_address_second_line,
string business_address_third_line, string business_address_country, string business_city,
string business_postcode, string business_land_line_phone_number, string business_mobile_phone_number,
string business_fax_number, string delivery_company_name, string delivery_address_first_line,
string delivery_address_second_line, string delivery_address_third_line,
string delivery_address_country, string delivery_city, string delivery_postcode, string delivery_telephone,
string contact_email_address, string pguk_account_no, string est_turnover, string comments,
string shipper_name, string shipper_address_first_line, string shipper_address_second_line,
string shipper_address_third_line, string shipper_address_city, string shipper_address_postcode,
string shipper_address_country, string shipper_telephone_number, string shipper_contact_person)
{
// get a configured DbCommand object
DbCommand comm = GenericDataAccess.CreateCommand();
// set the stored procedure name
comm.CommandText = "update_trade_customer";
// create a new parameter
// DataSource.InsertParameters.Add("UserId", UserGUID.ToString());
// DataSource.Insert();
//param.Value = shoppingCartId;
DbParameter param = comm.CreateParameter();
param.ParameterName = "@UserId";
param = comm.CreateParameter();
param.ParameterName = "@UserId";
param.Value = UserId;
param.DbType = DbType.Guid;
comm.Parameters.Add(param);
//param.Value = shoppingCartId;
//param = comm.CreateParameter();
//param.ParameterName = "@CartId";
//param.Value = CartId;
//param.DbType = DbType.Guid;
//comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@first_name";
param.Value = first_name;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@last_name";
param.Value = last_name;
param.DbType = DbType.String;
comm.Parameters.Add(param);
// create a new parameter
param = comm.CreateParameter();
param.ParameterName = "@company_name";
param.Value = company_name;
param.DbType = DbType.String;
comm.Parameters.Add(param);
// create a new parameter
param = comm.CreateParameter();
param.ParameterName = "@business_address_first_line";
param.Value = business_address_first_line;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@business_address_second_line";
param.Value = business_address_second_line;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@business_address_third_line";
param.Value = business_address_third_line;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@business_address_country";
param.Value = business_address_country;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@business_city";
param.Value = business_city;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@business_postcode";
param.Value = business_postcode;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@business_land_line_phone_number";
param.Value = business_land_line_phone_number;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@business_mobile_phone_number";
param.Value = business_mobile_phone_number;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@business_fax_number";
param.Value = business_fax_number;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@delivery_company_name";
param.Value = delivery_company_name;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@delivery_address_first_line";
param.Value = delivery_address_first_line;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@delivery_address_second_line";
param.Value = delivery_address_second_line;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@delivery_address_third_line";
param.Value = delivery_address_third_line;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@delivery_address_country";
param.Value = delivery_address_country;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@delivery_city";
param.Value = delivery_city;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@delivery_postcode";
param.Value = delivery_postcode;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@delivery_telephone";
param.Value = delivery_telephone;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@contact_email_address";
param.Value = contact_email_address;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@pguk_account_no";
param.Value = pguk_account_no;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@est_turnover";
param.Value = est_turnover;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@comments";
param.Value = comments;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@shipper_name";
param.Value = shipper_name;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@shipper_address_first_line";
param.Value = shipper_address_first_line;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@shipper_address_second_line";
param.Value = shipper_address_second_line;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@shipper_address_third_line";
param.Value = shipper_address_third_line;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@shipper_address_city";
param.Value = shipper_address_city;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@shipper_address_postcode";
param.Value = shipper_address_postcode;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@shipper_address_country";
param.Value = shipper_address_country;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@shipper_telephone_number";
param.Value = shipper_telephone_number;
param.DbType = DbType.String;
comm.Parameters.Add(param);
param = comm.CreateParameter();
param.ParameterName = "@shipper_contact_person";
param.Value = shipper_contact_person;
param.DbType = DbType.String;
comm.Parameters.Add(param);
// returns true in case of success or false in case of an error
try
{
// execute the stored procedure and return true if it executes
// successfully, or false otherwise
return (GenericDataAccess.ExecuteNonQuery(comm) != -1);
}
catch
{
// prevent the exception from propagating, but return false to
// signal the error
return false;
}
}