Formview - insert af initialer fra bruger
Jeg har et formview hvor jeg i min insert gerne vil undgå at skulle udfylde alle felter. Jeg vil gerne have feltet "createdby" til at være lig med min sessionsvariabel session("userittask"). HVad er den rigtige måde til at gøre sådan? Her lidt kode hvor jeg har skrællet en masse unødvendigt af. jeg har ikke noget i min codebehind fil. Kan jeg ikke klare det direkte vha parametrene her i mit formview. I gammel ASP ville jeg jo bare sige ... Values(newid(),session("userittask"), osv.. i min SQL sætning:)/wildthing
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:FormView ID="FormView1" runat="server" AllowPaging="True" DataKeyNames="GUID"
DataSourceID="DS_tasks">
<EditItemTemplate>
PIC:
<asp:TextBox ID="PICTextBox" runat="server" Text='<%# Bind("PIC") %>'>
</asp:TextBox><br />
Createdby:
<asp:TextBox ID="CreatedbyTextBox" runat="server" Text='<%# Bind("Createdby") %>'>
</asp:TextBox><br />
Createdon:
<asp:TextBox ID="CreatedonTextBox" runat="server" Text='<%# Bind("Createdon") %>'>
</asp:TextBox><br />
User_ini:
<asp:TextBox ID="User_iniTextBox" runat="server" Text='<%# Bind("User_ini") %>'>
</asp:TextBox><br />
category:
<asp:TextBox ID="categoryTextBox" runat="server" Text='<%# Bind("category") %>'>
</asp:TextBox><br />
Taskdesc:
<asp:TextBox ID="TaskdescTextBox" runat="server" Text='<%# Bind("Taskdesc") %>'>
</asp:TextBox><br />
Status:
<asp:TextBox ID="StatusTextBox" runat="server" Text='<%# Bind("Status") %>'>
</asp:TextBox><br />
Modifiedby:
<asp:TextBox ID="ModifiedbyTextBox" runat="server" Text='<%# Bind("Modifiedby") %>'>
</asp:TextBox><br />
Modifiedon:
<asp:TextBox ID="ModifiedonTextBox" runat="server" Text='<%# Bind("Modifiedon") %>'>
</asp:TextBox><br />
Taskdescshort:
<asp:TextBox ID="TaskdescshortTextBox" runat="server" Text='<%# Bind("Taskdescshort") %>'>
</asp:TextBox><br />
Attachedfiles:
<asp:TextBox ID="AttachedfilesTextBox" runat="server" Text='<%# Bind("Attachedfiles") %>'>
</asp:TextBox><br />
Solvedby:
<asp:TextBox ID="SolvedbyTextBox" runat="server" Text='<%# Bind("Solvedby") %>'>
</asp:TextBox><br />
Solvedon:
<asp:TextBox ID="SolvedonTextBox" runat="server" Text='<%# Bind("Solvedon") %>'>
</asp:TextBox><br />
Expected_solvedon:
<asp:TextBox ID="Expected_solvedonTextBox" runat="server" Text='<%# Bind("Expected_solvedon") %>'>
</asp:TextBox><br />
Solutiondesc:
<asp:TextBox ID="SolutiondescTextBox" runat="server" Text='<%# Bind("Solutiondesc") %>'>
</asp:TextBox><br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="Update">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="GUIDTextBox" runat="server" Text='<%# Bind("GUID") %>' Visible="False"></asp:TextBox><br />
PIC:
<asp:TextBox ID="PICTextBox" runat="server" Text='<%# Bind("PIC") %>'></asp:TextBox><br />
<asp:TextBox ID="CreatedbyTextBox" runat="server" Text='<%# Bind("Createdby") %>' Visible="False"></asp:TextBox><br />
<asp:TextBox ID="CreatedonTextBox" runat="server" Text='<%# Bind("Createdon") %>' Visible="False"></asp:TextBox><br />
User_ini:
<asp:TextBox ID="User_iniTextBox" runat="server" Text='<%# Bind("User_ini") %>'></asp:TextBox><br />
category:
<asp:TextBox ID="categoryTextBox" runat="server" Text='<%# Bind("category") %>'></asp:TextBox><br />
Taskdesc:
<asp:TextBox ID="TaskdescTextBox" runat="server" Text='<%# Bind("Taskdesc") %>'></asp:TextBox><br />
Status:
<asp:TextBox ID="StatusTextBox" runat="server" Text='<%# Bind("Status") %>' Visible="False"></asp:TextBox><br />
Modifiedby:
<asp:TextBox ID="ModifiedbyTextBox" runat="server" Text='<%# Bind("Modifiedby") %>' Visible="False"></asp:TextBox><br />
Modifiedon:
<asp:TextBox ID="ModifiedonTextBox" runat="server" Text='<%# Bind("Modifiedon") %>' Visible="False"></asp:TextBox><br />
Taskdescshort:
<asp:TextBox ID="TaskdescshortTextBox" runat="server" Text='<%# Bind("Taskdescshort") %>'></asp:TextBox><br />
Attachedfiles:
<asp:TextBox ID="AttachedfilesTextBox" runat="server" Text='<%# Bind("Attachedfiles") %>'></asp:TextBox><br />
Solvedby:
<asp:TextBox ID="SolvedbyTextBox" runat="server" Text='<%# Bind("Solvedby") %>' Visible="False"></asp:TextBox><br />
Solvedon:
<asp:TextBox ID="SolvedonTextBox" runat="server" Text='<%# Bind("Solvedon") %>' Visible="False"></asp:TextBox><br />
Expected_solvedon:
<asp:TextBox ID="Expected_solvedonTextBox" runat="server" Text='<%# Bind("Expected_solvedon") %>'></asp:TextBox><br />
Solutiondesc:
<asp:TextBox ID="SolutiondescTextBox" runat="server" Text='<%# Bind("Solutiondesc") %>' Visible="False"></asp:TextBox><br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="Insert" OnClick="InsertButton_Click"></asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel"></asp:LinkButton>
</InsertItemTemplate>
<ItemTemplate>
<br />
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="new">Add task</asp:LinkButton>
</ItemTemplate>
<EmptyDataTemplate>
db is empty
</EmptyDataTemplate>
</asp:FormView>
<asp:SqlDataSource ID="DS_tasks" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:ITtasksConnectionString %>"
InsertCommand="INSERT INTO [tasks] ([GUID], [PIC], [Createdby], [Createdon], [User_ini], [category], [Taskdesc], [Status], [Modifiedby], [Modifiedon], [Taskdescshort], [Attachedfiles], [Solvedby], [Solvedon], [Expected_solvedon], [Solutiondesc]) VALUES (newID(), @PIC, @Createdby, @Createdon, @User_ini, @category, @Taskdesc, @Status, @Modifiedby, @Modifiedon, @Taskdescshort, @Attachedfiles, @Solvedby, @Solvedon, @Expected_solvedon, @Solutiondesc)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [tasks]"
>
<InsertParameters>
<asp:Parameter Name="PIC" Type="String" />
<asp:Parameter Name="Createdby" Type="String" />
<asp:Parameter Name="Createdon" Type="DateTime" />
<asp:Parameter Name="User_ini" Type="String" />
<asp:Parameter Name="category" Type="String" />
<asp:Parameter Name="Taskdesc" Type="String" />
<asp:Parameter Name="Status" Type="String" />
<asp:Parameter Name="Modifiedby" Type="String" />
<asp:Parameter Name="Modifiedon" Type="DateTime" />
<asp:Parameter Name="Taskdescshort" Type="String" />
<asp:Parameter Name="Attachedfiles" Type="String" />
<asp:Parameter Name="Solvedby" Type="String" />
<asp:Parameter Name="Solvedon" Type="DateTime" />
<asp:Parameter Name="Expected_solvedon" Type="DateTime" />
<asp:Parameter Name="Solutiondesc" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
</asp:Content>