You need to sign in to do that
Don't have an account?

how to Display list of values using List<string>
Hi,
Controller
================
public class ListPrimitiveDataype
{
public List<String> fstName{get;set;}
public List<String> lstName{get;set;}
public ListPrimitiveDataype()
{
fstName= New List<String>();
lstName= New List<String>();
}
public List<String> getfstName()
{
List<String> lst = New List<String>();
lst.add('anil');
return lst;
}
}
page
=================
<apex:page controller="ListPrimitiveDataype">
<apex:form >
<apex:pageBlock>
<apex:pageblockTable value="{!fstName}" var="f">
<apex:column value="{!f.lst}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
i have error message here " Error: Unknown property 'String.lst' .....
please help me
try this
you were not declaring the variable.
public class ListPrimitiveDataype
{
Public List<String> fstName{get;set;}
public ListPrimitiveDataype()
{
fstName= New List<String>();
fstName.add('praveen');
fstName.add('anil');
fstName.add('karthik');
}
}
All Answers
try this
you are displaying the list<string> so you do not need any dot notation
Vf Page :
<apex:page controller="ListPrimitiveDataype">
<apex:form >
<apex:pageBlock >
<apex:pageblockTable value="{!fstName}" var="f">
<apex:column value="{!f}"/>
</apex:pageblockTable>
<apex:pageblockTable value="{!lstName}" var="f">
<apex:column value="{!f}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Apex Class:
public class ListPrimitiveDataype
{
public List<String> fstName{get;set;}
public List<String> lstName{get;set;}
public ListPrimitiveDataype()
{
fstName= New List<String>();
lstName= New List<String>();
fstName.add('fstName element1');
fstName.add('fstName element2');
fstName.add('fstName element3');
lstName.add('lstName element1');
lstName.add('lstName element2');
lstName.add('lstName element3');
}
}
Hi,
Please try the below code and let me know if it works.
Thanks,
Praveen K.
Sorry, please correct this and try..
try this
you were not declaring the variable.
public class ListPrimitiveDataype
{
Public List<String> fstName{get;set;}
public ListPrimitiveDataype()
{
fstName= New List<String>();
fstName.add('praveen');
fstName.add('anil');
fstName.add('karthik');
}
}
Thanks for the correction Laxman..
I was just provided the way to display..
i thought it was palli.
Thank you very much Laxman........
Thank u very much Praveen
hi Laxman now how to display set<string> values in the same manner.........
please help me
yes you have to display in same manner.
replace list with set..
but make sure set will not accept duplicates strings..
Thanks,
Praveen K.