Click here to Skip to main content
15,894,955 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created SignUp Form In Asp.net in this I am Using SQL Server Database. I Have Two Table Like EducationInfo and UserInfo . EducationInfo Table contain following column (EduId(PK),User_Id(FK),Degree,University,Passing Year,Percentage) and UserInfo Table contain following column (User_Id(PK),UserName,Password,FirstName,MiddleName,LastName,Country,City).

And finally i have create below form Like First Of User Fill Up Personal Information (FirstName,MiddleName,LastName,Coutry,City) than Education Information(Degree,University,Passing Year,Percentage) than Bind Grid Education Info than User Information (UserName,Password) .


In this form i have problem in insert data how in education info table and UserInfo table.

Without UserId how i am inserting in educationinfo table data....so help me sir/mem...


<body>
<form id="form1" runat="server">

------- Personal Info --------
<asp:Label ID="LblFname" runat="server" Text="FirstName">
<asp:TextBox ID="TxtFname" runat="server">
<asp:Label ID="LblMName" runat="server" Text="MiddleName">
<asp:TextBox ID="TxtMName" runat="server">
<asp:Label ID="LblLName" runat="server" Text="LastName">
<asp:TextBox ID="TxtLName" runat="server">
<asp:Label ID="LblCountry" runat="server" Text="Country">
<asp:TextBox ID="TxtCountry" runat="server">
<asp:Label ID="LblCity" runat="server" Text="City">
<asp:TextBox ID="TxtCity" runat="server">
------- Education Info --------
<asp:Label ID="LblDegree" runat="server" Text="Degree">
<asp:TextBox ID="TxtDegree" runat="server">
<asp:Label ID="LblUniversity" runat="server" Text="University">
<asp:TextBox ID="TxtUniversity" runat="server">
<asp:Label ID="LblPassingYear" runat="server" Text="Passing Year">
<asp:TextBox ID="TxtPassingYear" runat="server">
<asp:Label ID="LblPercentage" runat="server" Text="Percentage">
<asp:TextBox ID="TxtPercentage" runat="server">
<asp:Button ID="BtnAddDegree" runat="server" Text="Add Degree" Style="margin-left: 23%;" OnClick="BtnAddDegree_Click" />
<asp:Label ID="LblResultDegree" runat="server">
<asp:ListView ID="LstSignUp" runat="server">
<emptydatatemplate>

<asp:Label ID="LblEmptyData" runat="server">


<layouttemplate>

<tr id="itemPlaceholder" runat="server">

<asp:Label ID="GrdHDegree" runat="server" Text="Degree" >


<asp:Label ID="GrdHUniversity" runat="server" Text="University" >


<asp:Label ID="GrdHPYear" runat="server" Text="Passing Year" >


<asp:Label ID="GrdHPercentage" runat="server" Text="Percentage">



<itemtemplate>

<asp:Label ID="GrdRDegree" runat="server" Text='<%#Eval("Degree") %>' >
<asp:Label ID="GrdRUniversity" runat="server" Text='<%#Eval("University") %>' >
<asp:Label ID="GrdRPYear" runat="server" Text='<%#Eval("Passing_Year") %>' >
<asp:Label ID="GrdRPercentage" runat="server" Text='<%#Eval("Percentage") %>' >










------- User Info --------
<asp:Label ID="LblUname" runat="server" Text="UserName">
<asp:TextBox ID="TxtUname" runat="server">
<asp:RequiredFieldValidator ID="RfvUname" runat="server" ControlToValidate="TxtUname" Text="Please Enter UserName" ValidationGroup="VG" CssClass="reqerror">
<asp:Label ID="LblPwd" runat="server" Text="Password">
<asp:TextBox ID="TxtPwd" runat="server" TextMode="Password">
<asp:RequiredFieldValidator ID="RfvPwd" runat="server" ControlToValidate="TxtPwd" Text="Please Enter Password" ValidationGroup="VG" CssClass="reqerror">
<asp:Button ID="BtnSubmit" runat="server" Text="Submit" Style="margin-left: 35%;" ValidationGroup="VG" OnClick="BtnSubmit_Click" />
<asp:Label ID="lblResult" runat="server">

</form>
</body>
Posted
Comments
keyur_raval 1-Jul-14 5:08am    
Anyone please quickly reply me......

1 solution

First insert data in UserInfo table and get the identity column in the same query. Using the identity value insert the educationinf data.



Here's an example of how that works:

C#
var dc = new MyDataContext();
var cust = new Customer{FirstName="John", LastName="Smith"};
dc.Customer.InsertOnSubmit(cust);
dc.SubmitChanges();
//after SubmitChanges(), the Id is filled from the database
var customerPrimaryKey = cust.Id;
 
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