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

How to Select all the Firstname from the Tab?
Hi,
In my applicaton i using Contace tab.. I want select all the Firstname only from here. and also to bind the all the Firstname in asp.net page dropdown list.. When I m trying this task i got error like "System.QueryException: List has more than 1 row for assignment to SObject"
Can You please solve the problem?
My Apex Class Code :
My aspx Code Behind:
In my applicaton i using Contace tab.. I want select all the Firstname only from here. and also to bind the all the Firstname in asp.net page dropdown list.. When I m trying this task i got error like "System.QueryException: List has more than 1 row for assignment to SObject"
Can You please solve the problem?
My Apex Class Code :
global class getUserName{ WebService static Lead getLeadUserName() { Lead c = [SELECT FirstName FROM Lead ]; Lead l= new Lead(FirstName =c.FirstName); return l; } }
My aspx Code Behind:
getUserName.getUserNameService getUserNameObj = new getUserName.getUserNameService(); getUserNameObj.SessionHeaderValue = new getUserName.SessionHeader(); getUserNameObj.SessionHeaderValue.sessionId = sessionId; getUserName.Lead getUserNameResponse = getUserNameObj.getLeadUserName(); ddlUserName.Items.Add(getUserNameResponse.FirstName);
Hi,
global class getUserName{
WebService static Lead getLeadUserName() {
List<Lead> leadList = [SELECT FirstName FROM Lead ];
List<Lead> ll = new List<Lead>();
if(leadList.size() > 0){
Lead l= new Lead(FirstName =c.FirstName);
ll.add(l);
}
return ll;
}
}
Try this.
I try this Ur code.... But I got error... pls help me to clear the bug...
Code
Error
Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST<Contact> at line 8 column 38
Hi,
Try this.
global class getTeacherName{
WebService static Contact getTeacherName() {
List<Contact> contactList = [SELECT FirstName,Password__c FROM Contact WHERE ContactType__c='teacher'];
List<Contact> l1 = new List<Contact>();
if(contactList.size()>0){
for(Contact c : contactList){
Contact l=new Contact(FirstName =c.FirstName);
l1.add(l);
}
}
return l1;
}
}
Attempt
global class getTeacherName{
WebService static Contact getTeacherName() {
List<Contact> contactList = [SELECT FirstName,Password__c FROM Contact WHERE ContactType__c='teacher'];
List<Contact> l1 = new List<Contact>();
if(contactList.size()>0){
for(Contact c : contactList){
Contact l=new Contact(FirstName =c.FirstName);
l1.add(l);
}
}
return l1;
}
}
Error
global class getTeacherName{
WebService static List<Contact> getTeacherName(){
List<Contact> contactList = [SELECT FirstName,Password__c FROM Contact WHERE ContactType__c='teacher'];
List<Contact> l1 = new List<Contact>();
if(contactList.size()>0){
for(Contact c : contactList){
Contact l=new Contact(FirstName =c.FirstName);
l1.add(l);
}
}
return l1;
}
}
This one
Aspx Code:
getTeacherName.getTeacherNameService getTeacherInfoObj = new getTeacherName.getTeacherNameService();
getTeacherInfoObj.SessionHeaderValue = new getTeacherName.SessionHeader();
getTeacherInfoObj.SessionHeaderValue.sessionId = sessionId;
getTeacherName.Contact getTeacherInfoResponse = getTeacherInfoObj.getTeacherName;
ddlUserName.Items.Add(getTeacherInfoResponse.FirstName);
Error:
Cannot convert method group 'getTeacherName' to non-delegate type 'SFLeadLookup.getTeacherName.Contact'. Did you intend to invoke the method?
1. How to solve this issue?
2. How debud the Apex Code?