Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public int InsertRegistrationDetails()
 { 
 SqlCommand cmd = new SqlCommand("sp_Registration",con);
 cmd.CommandType = CommandType.StoredProcedure;
 cmd.Parameters.Add("@CustomerId", CustomerId);
 cmd.Parameters.Add("@EmailId",EmailId);
 cmd.Parameters.Add("@FirstName",FirstName);
 cmd.Parameters.Add("@Lastname",Lastname);
 cmd.Parameters.Add("@Phone1",Phone1);
 cmd.Parameters.Add("@Phone2",Phone2);
 cmd.Parameters.Add("@CompanyName",CompanyName); 
 cmd.Parameters.Add("@Address",Address);
 cmd.Parameters.Add("@ZipCode",ZipCode);
 cmd.Parameters.Add("@City",City);
 cmd.Parameters.Add("@State",State);
 cmd.Parameters.Add("@Country",Country);
 cmd.Parameters.Add("@TransactionDate",TransactionDate);
 cmd.Parameters.Add("@Status",Status);
 cmd.ExecuteNonQuery(); 
 int NewId = 0; 
 NewId = Convert.ToInt32(cmd.ExecuteScalar().ToString());
 return NewId; }

this is a class. this function returns scalar value. how to take that value in code behind and assign this return value to customer id
Posted
Updated 22-Aug-12 0:43am
v3
Comments
Christian Graus 22-Aug-12 6:37am    
What do you mean by customer id ? In the database ? In a control ? Visibly, or as a hidden value ? The code you posted is irrelevant. Where the number comes from does not matter at all. You say 'code behind' but your question is not tagged as ASP.NET. This is a vague question that needs more information
Santhosh Kumar Jayaraman 22-Aug-12 6:39am    
you already wrote that method in code behind.Then whats ur problem?
Lakshmimsridhar 22-Aug-12 6:55am    
customer id is a primary key in database
Lakshmimsridhar 22-Aug-12 6:54am    
above is a class not aspx.cs page i need to assign it in aspx.cs page.

1 solution

Are you saying this a class? How can you have return variable for class?
This is a method.

I think you need to set customer Id value to some label on button click isnt it?

On your button click code behind
C#
int CustomerId=InsertRegistrationDetails();


or

C#
Label1.Text=InsertRegistrationDetails().ToString().
 
Share this answer
 
Comments
Lakshmimsridhar 22-Aug-12 7:25am    
thank u so much It works well:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900