You need to sign in to do that
Don't have an account?
SFDCU$er
Add values to a table dynamically
I have a visualforce page with input text Student Name and an Add Button. When I enter a value and click Add It should add the name in the table below along with the created date and Student number which would be an auto-number field.
So far this is what I have done:
Wrapper Class:
Visualforce Page:
StudentRosterController:
Please help.
So far this is what I have done:
Wrapper Class:
public with Sharing class WrapperClass{ public class StudentRosterData{ public Date DateCreated { get; set; } public String Name { get; set; } public Integer StudentNumber { get; set; } } public StudentRosterData studentData{get; set;} public WrapperClass(){ studentData = new StudentRosterData(); } }
Visualforce Page:
<apex:page controller="StudentRosterController"> <apex:form > Student Name: <apex:inputText value="{!Names}" /> <apex:commandButton value="Add" action="{!AddNames}"/> <table border="0"> <tr> <td><b>Name</b></td> <td><b> Entered Date</b> </td> </tr> <apex:repeat value="{!wrapper.studentData}" var="stu"> <tr> <td> <apex:outputText value="{!stu.Name}"/></td> <td> <apex:outputText value="{!stu.StudentNumber}"/></td> <td> <apex:outputText value="{!stu.DateCreated}"/></td></tr> </apex:repeat> </table> </apex:form> </apex:page>
StudentRosterController:
public class StudentRosterController{ public String Names { get; set; } public WrapperClass wrapper{get; set;} public pageReference AddNames() { WrapperClass.StudentRosterData addstudent = new WrapperClass.StudentRosterData(); wrapper.studentData.Name = Names; wrapper.studentData.DateCreated = Date.today(); return null; } }
Please help.
You have to make following changes in your Controllers.
WrapperClass
Visualforce Page:
StudentRosterController:
Thank You,
Hitesh Patel
SFDC Certified Developer & Administrator & Advanced Administrator & Sales cloud consultant
Email :- hiteshpatel.aspl@gmail.com
My Blog:- http://mrjavascript.blogspot.in/