About Me

My photo
a Dynamic and Energetic guy.....

Thursday, July 24, 2008

System.Diagnostics.StackTrace lobjStack = new System.Diagnostics.StackTrace();

//Get the immediate caller

System.Diagnostics.StackFrame lobjCaller = lobjStack.GetFrame(1);

System.Reflection.MethodBase lobjMethodBase = lobjCaller.GetMethod();

string lstrCallingModule = lobjMethodBase.ReflectedType.FullName;

return lstrCallingModule; // this will return the name of the class

// you can use this to get function name also



Tuesday, July 15, 2008

Dynamically Creating a CustomList, With Lookup field

private void setAlist()

{

try

{

SPWeb web = site.AllWebs[ConfigurationManager.AppSettings["WEB_SITE"].ToString()];

web.AllowUnsafeUpdates = true;


SPList oldList = web.Lists["Subject"];

System.Guid oldGuid = oldList.ID;


System.Guid id = web.Lists.Add("ChanakaNEW", "", SPListTemplateType.GenericList);

SPList MCQList = web.Lists["ChanakaNEW"];

System.Guid iddd = MCQList.ID;

web.Lists[iddd].Fields.Add("StudentID", SPFieldType.Text, true);

web.Lists[iddd].Fields.Add("Marks", SPFieldType.Number, false);

web.Lists[iddd].Fields.AddLookup("Try",oldGuid,false);

//web.Lists[iddd].Fields.Add("Trying", oldGuid, false);


foreach (ListItem listOf in listNames)

{

SPList newList = web.Lists["ChanakaNEW"];

SPListItem newListItem = newList.Items.Add();

//if ((!IsExist(name)) && (!name.Equals(string.Empty)))

{

newListItem["StudentID"] = listOf.Text;

newListItem["Marks"] = 3;

newListItem["Try"] = int.Parse(listOf.Value);

newListItem.Update();

}

}

}

catch(Exception ex)

{

Response.Write(ex.Message);

}

}

My Masters