This is a migrated thread and some comments may be shown as answers.

adding items to automatic operationes (insert, update, delete)

1 Answer 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 20 Sep 2011, 06:32 PM
Looking for a way to use an autogenerated edit form and automatic operations but add properties such as logged in user and date and time for an insert or update.  Is there a way to append items to what is being inserted using the grid's operations or is doing it on the data source the better option?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Sep 2011, 05:39 AM
Hello Jeremy,

Try the folowing markup and code snippet to add items to automatic operations.
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
        SelectCommand="Select * from Table" InsertCommand="insert into Table(AdminID,AdminName,Password,DateTime)values(@AdminID,@AdminName,@Password,@DateTime)"
<InsertParameters>
         <asp:Parameter Name="AdminID" />
         <asp:Parameter Name="AdminName" />
         <asp:Parameter Name="Password" />
         <asp:SessionParameter Name="DateTime" DbType="DateTime" SessionField="DateTime"  />
</InsertParameters>
</asp:SqlDataSource>
C#:
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
 {
   Session["DateTime"] = DateTime.Now;
 }

Thanks,
Shinu.
Tags
Grid
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or