суббота, 20 марта 2010 г.

How to add the insert/update parameter for ASP .Net SqlDataSource

For example I am using DetailsView and SqlDataSourece. I want to insert new item to the collection using Insert DetailsViewMode. But this item have some parameters that are not present in ReadOnly DetailsViewMode. The question how to add additional parameters to the data item and pass it to the SqlDataSourece InsertCommand.

The answer is simple, follow next sample:

    protected void LeadsSqldatasource_Inserting1(object sender, SqlDataSourceCommandEventArgs e)
        SqlParameter userName = new SqlParameter("@UserName", SqlDbType.NVarChar);
        userName.Value = User.Identity.Name;

Комментариев нет: