This is my UserControl.ascx.cs partial class
namespace SP.ExampleProject.CONTROLTEMPLATES
{
public partial class ExampleProjectUserControl : UserControl
{
public SPUser currentSuperUser = SPContext.Current.Web.CurrentUser;
protected void Page_Load(object sender, EventArgs e)
{
int id = this.ListItem.ID; // Can't use ListItem
SPWeb web = Utility.GetWebWithSystemPermissions(SPContext.Current.Web);
SPList Decision_List = web.GetList(Utility.GetServerRelativeUrl(web) + "Lists/Decisions");
SPFieldUserValue boss = new SPFieldUserValue(web, this.ListItem["Bosses"].ToString()); // Can't use ListItem too
SPListItem item = Desicion_List.GetItemById(id);
}
}
}
I can't use "ListItem" in this class.
So;
How can I access to my list items from partial class?
How can I use boss variable in ascx?
I wanna this because I want to compare currentUser.ID with boss.User.ID in ascx file and show special fields on template.
Thanks in advance
protected int GetBossId()
{
return new SPFieldUserValue(SPContext.Current.Web, SPContext.Current.ListItem["Bosses"].ToString()).LookupId;
}
Delete all. and write this function. And now U can get BossID at Usercontrol.ascx