Click here to Skip to main content
14,662,530 members
Home » Discussions » SharePoint
   

SharePoint

 
GeneralRe: SharePoint 2010 Site Alerts Possible??? Pin
Grzadl11-Jun-12 14:01
MemberGrzadl11-Jun-12 14:01 
AnswerRe: SharePoint 2010 Site Alerts Possible??? Pin
.Net Jim11-Jun-12 22:03
Member.Net Jim11-Jun-12 22:03 
QuestionHow to edit an infopath form after publishing it to sharepoint. Pin
fresh120730-May-12 2:28
Memberfresh120730-May-12 2:28 
AnswerRe: How to edit an infopath form after publishing it to sharepoint. Pin
nandakumar_mct19-Jun-12 4:57
Membernandakumar_mct19-Jun-12 4:57 
AnswerRe: How to edit an infopath form after publishing it to sharepoint. Pin
ssivarao3-Jul-12 0:24
Memberssivarao3-Jul-12 0:24 
QuestionSharepoint site - when user logging in for 2nd time without proper logout, it doesnt ask for password Pin
nainakarri28-May-12 1:40
Membernainakarri28-May-12 1:40 
AnswerRe: Sharepoint site - when user logging in for 2nd time without proper logout, it doesnt ask for password Pin
.Net Jim28-May-12 12:47
Member.Net Jim28-May-12 12:47 
QuestionAdd values to a list contains a Lookup Field Pin
Georby24-May-12 23:54
MemberGeorby24-May-12 23:54 
I have a list named "Designation" that contains a Designation Code and Designation Name. I have another list named "Employee" that contains Employee Name and Designation Name (as a Lookup Field). I am able to insert values to "Employee" list using the following code.

protected void AddEmp(object sender, EventArgs e)
{
string emp_name = txtEmployeeName.Text;
string emp_designation = ddlDesignation.SelectedValue;
using (SPSite site = new SPSite("My Site"))
{
using (SPWeb web = site.OpenWeb())
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
web.AllowUnsafeUpdates = true;
SPList splist_employees = web.Lists["Employee"];
SPList splist_designations = web.Lists["Designations"];
SPListItemCollection splc_items = splist_employees.Items;
SPListItem spli_item = splc_items.Add();
SPFieldLookup lookup = splist_employees.Fields["Designated"] as SPFieldLookup;
string fieldName = lookup.LookupField;
spli_item["Employee Name"] = emp_name;
spli_item[fieldName] = GetLookFieldIDS(emp_designation, splist_designations);
spli_item.Update();
});
}
}
}

public static string GetLookFieldIDS(string lookupValues, SPList lookupSourceList)
{
string id = string.Empty;
SPFieldLookupValueCollection lookupIds = new SPFieldLookupValueCollection();
SPQuery query = new Microsoft.SharePoint.SPQuery();
query.Query = "<where><eq><fieldref name="Designation"><value type="Text">"+lookupValues + "";
SPListItemCollection listItems = lookupSourceList.GetItems(query);
foreach (Microsoft.SharePoint.SPListItem item in listItems)
{
id = item.ID.ToString();
}
return id;
}

Here I have given the field name as 'Designation' inside the query.

But, I want to find the field name based on the value given from the user end instead of hard-coding the field name as 'Designation'.

Any help is greatly appreciated. Thanks in advance.
AnswerRe: Add values to a list contains a Lookup Field Pin
Not Active25-May-12 2:30
mentorNot Active25-May-12 2:30 
QuestionHow to provide least priveilge account for sharepoint server 2010 Pin
santhoshmohan22-May-12 22:18
Membersanthoshmohan22-May-12 22:18 
AnswerRe: How to provide least priveilge account for sharepoint server 2010 Pin
Not Active23-May-12 2:29
mentorNot Active23-May-12 2:29 
QuestionCalling javascript for a SharePoint webpart? Pin
Steve Holdorf21-May-12 0:55
MemberSteve Holdorf21-May-12 0:55 
AnswerRe: Calling javascript for a SharePoint webpart? Pin
Steve Holdorf21-May-12 2:06
MemberSteve Holdorf21-May-12 2:06 
AnswerRe: Calling javascript for a SharePoint webpart? Pin
Not Active21-May-12 2:14
mentorNot Active21-May-12 2:14 
GeneralRe: Calling javascript for a SharePoint webpart? Pin
Steve Holdorf21-May-12 2:57
MemberSteve Holdorf21-May-12 2:57 
GeneralRe: Calling javascript for a SharePoint webpart? Pin
Not Active21-May-12 3:12
mentorNot Active21-May-12 3:12 
GeneralRe: Calling javascript for a SharePoint webpart? Pin
Steve Holdorf21-May-12 4:10
MemberSteve Holdorf21-May-12 4:10 
GeneralRe: Calling javascript for a SharePoint webpart? Pin
Not Active21-May-12 4:27
mentorNot Active21-May-12 4:27 
GeneralRe: Calling javascript for a SharePoint webpart? Pin
Steve Holdorf21-May-12 4:40
MemberSteve Holdorf21-May-12 4:40 
GeneralRe: Calling javascript for a SharePoint webpart? Pin
Steve Holdorf21-May-12 6:11
MemberSteve Holdorf21-May-12 6:11 
Questionsamples for creating workflows in sharepoint 2007 Pin
RoshInd17-May-12 22:33
MemberRoshInd17-May-12 22:33 
AnswerRe: samples for creating workflows in sharepoint 2007 Pin
Not Active18-May-12 1:07
mentorNot Active18-May-12 1:07 
AnswerRe: samples for creating workflows in sharepoint 2007 Pin
santhoshmohan22-May-12 22:23
Membersanthoshmohan22-May-12 22:23 
QuestionWebPart Error Pin
Steve Holdorf14-May-12 10:25
MemberSteve Holdorf14-May-12 10:25 
AnswerRe: WebPart Error Pin
Not Active14-May-12 14:53
mentorNot Active14-May-12 14:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.