Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
USING ASP.NET(C#) WITH SQL SERVER 2008
during signup by applicant he/she must fill her educational details , total 5 educational levels,

1.ssc

2.hssc

3. BS

4. MS

5. Phd

now lets say that an applicant has only BS passed then it mean that he/she would not have fill 4 and 5 option, now i want that there should be an option in signup page to add rows dynamically , say for 3 levels of education only to add and fill 3 rows of text boxes, so how ?

or if u ppl have any other alternative then share please

Here is my Database table structure to which i want ot add data from asp.net(c#) website.

ACADEMIC RECORD

educationLvl

examName

institution

passingYear

marksObtained

division

percentage

majorSub
Posted

1. Create a user control and place one row of textbox/dropdowns (say Education, Major, percentage etc) + a button ("Add").
2. Add a placeholder in your page add this usercontrol dynamically to the page.
something like placeHolder.Controls.Add("/....usercontrol.ascx");
3. On click of the button, append one more control to the placeholder.

Since these are Dynamic controls, need to create them on each postback.

Let me know if you are fine with this approach.. if so I can provide more inputs.
 
Share this answer
 
Comments
Hunain Hafeez 19-Oct-12 16:11pm    
thanks dear, nyc, but please elaborate more, especially usercontrol approach
bu
1. Create a user control with the controls you want.
2. Expose properties within the usercontrol to get each of the cotnrol values.
eg: public string Education
{
get { your control value }
}
3. Specify a asp.net place holder on your page for the usercontrol.
4. add a server side hidden control to capture the usercontrolcount or use viewstate and assign the usercontrol count.
for example you have to show by default one row so set initially the control count as 1.
viewstate["controlcount"] = 1;
5. on page_load everytime check for the control that fired the postback (if any ). this is to check the Add button click event.
if postbACK control name is "btnAdd" the increment the viewstate["controlcount"] value by 1;
6. on page load you need to create the usercontrols based on the viewstate["controlcount"] value
something like
for (int i=0; i< viewstate["controlcount"] ; ....)
{
usercontrol ctl = Loadcontrol (./....../myusercontrol.ascx)
ctl.id = "ucID" + i //this is to create a unique id;
placeholder.Controls.add(ctl);
}

you are done.
Call this every page_load call as the controls are loaded dynamically so everytime you need to create the same.
 
Share this answer
 
Comments
Hunain Hafeez 19-Oct-12 16:40pm    
thanks alot man,,,,,
christhomps 28-Oct-12 4:41am    
i was searching for the same.
Thanks Milan.

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