Click here to Skip to main content
15,889,858 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai all, i have a problem like after user registration user will redirect to another page and i have to catch some credentials in sessions and insert those valus along with second page credentials



i got email and name but what can i do for catch id any help

TIA

What I have tried:

C#
public ActionResult UserRegistration(Tbl_Registration user)
      {
          string name = null, Email = null;
          int userid = 0;


          int i = v.InsertUserRegistration(user.Name, user.Gender,user.email);
          //storing data in session for nexpage
          if (i>0)
          {


              Session["Id"] = user.Id;--id is 0 here
             Session["Name"] = user.Name;

             Session["EmailId"] = user.EmailId;
Posted
Updated 30-May-16 1:28am
Comments
ZurdoDev 17-May-16 12:53pm    
It's your code. Why can't you get the ID?

C#
Session["Id"] = user.Id;--id is 0 here


Nothing has updated user.Id so it stays at 0. Try

C#
user.Id = i;
Session["Id"] = user.Id;


or

C#
Session["Id"] = i;
 
Share this answer
 
Comments
Member 12519727 17-May-16 13:09pm    
Thanks for your reply sir,but here in DAL i wrote for inserting i.e; "i" is related to executenonquery() so i think here "i" means always 1 ..so it wont work sir
F-ES Sitecore 17-May-16 15:35pm    
Change InsertUserRegistration to accept "Tbl_Registration user" as a param rather than the email, name and gender individually as strings, then that function can update user.Id and that new id will be seen in your code after the function call.
C#
Related to ExecuteNonquery(); , it will return the no of rows affected, so it will "1" if your query worked in database else "0" if query failed due to any reasons.

Here, you can cross check whether user.Id is initialised or not before coming to this block
 
Share this answer
 
Hi, I would guess that your argument "Tbl_Registration user" don't have the Id set. If you hit your If block. Then var "i" must be bigger then "0", can't happen to be that the user id is stored there?
 
Share this answer
 

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