Morning Imar
I am creating a page that will allow users to insert a review and I am mirroring page NewPhotoAlbum.aspx.
At present the details view will insert a record but not the username.
VWD does not pick any errors when compiling the code.
Below is my code.
Code:
protected void LinqDataSource1_Inserting(object sender, LinqDataSourceInsertEventArgs e)
{
Review myReview = (Review)e.NewObject;
myReview.UserName = User.Identity.Name;
}
Code:
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
<h1>Hi there visitor create your photo book</h1>
<p>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
DataKeyNames="Id" DataSourceID="LinqDataSource1" DefaultMode="Insert"
Height="50px" Width="125px">
<Fields>
<asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False"
ReadOnly="True" SortExpression="Id" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Summary" HeaderText="Summary"
SortExpression="Summary" />
<asp:BoundField DataField="Body" HeaderText="Body" SortExpression="Body" />
<asp:BoundField DataField="GenreId" HeaderText="GenreId"
SortExpression="GenreId" />
<asp:CheckBoxField DataField="Authorized" HeaderText="Authorized"
SortExpression="Authorized" />
<asp:BoundField DataField="CreateDateTime" HeaderText="CreateDateTime"
SortExpression="CreateDateTime" />
<asp:BoundField DataField="UpdateDateTime" HeaderText="UpdateDateTime"
SortExpression="UpdateDateTime" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="iGigDataContext" EnableInsert="True" TableName="Reviews">
</asp:LinqDataSource>
</p>
</asp:Content>
If you could take a look at my code that would be great.
Thanks
Hippo