I am creating application page. On this application page I want to update some SharePoint fields in my List.
So I have created this in aspx file:
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<SharePoint:TextField ControlMode="Edit" runat="server" FieldName="Size" ID="SizeField"></SharePoint:TextField>
</asp:Content>
In cs Page_Load I have this
protected void Page_Load(object sender, EventArgs e)
{
SPList list = SPContext.Current.Web.Lists["Media Content"];
SizeField.ListId = list.ID;
SizeField.ItemId = 5;
}
But When I load the page I got Error.
But When I add to aspx this (ListId and ItemId directly in aspx)
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<SharePoint:TextField ControlMode="Edit" runat="server" FieldName="Size" ID="SizeField" ListId="7a00ae8c-9e8d-4762-81a2-a21b76a24ea7" ItemId="5"></SharePoint:TextField>
</asp:Content>
And Page load in cs is empty it works without any problem....
But I want to change ItemId and ListId dynamically in cs code....Hmm...Thank you
PS: I try also add initialization to OnInit or in CreateChildControls but without success. Thanks