Prepopulate a value in detailview during insert

I want to prepopulate 3 fields (project, month and year) from a querystring when I do an insert on a detailsview.  how do I do this?
MrTimewalkAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
You can handle the ItemInserting event and modify the data prior to the insert:

    protected void YourDetailsView_ItemInserting(object sender, DetailsViewInsertEventArgs e)
    {
        e.Values["yourColumn"] = Request.QueryString["yourValue"];  
    }
0
 
Carl TawnSystems and Integration DeveloperCommented:
You may, of course, need to cast your QueryString value to the correct type for the column.
0
 
MrTimewalkAuthor Commented:
DOESN'T WORK
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
MrTimewalkAuthor Commented:
does not populate the values
0
 
Carl TawnSystems and Integration DeveloperCommented:
Are you getting any errors ? How are you populating the data ? Are you bound to a DataSource ?
0
 
MrTimewalkAuthor Commented:
   Protected Sub detailsview1_inserting(ByVal sender As Object, ByVal e As DetailsViewInsertEventArgs)
        e.Values("InsertYear") = Request.QueryString("year")
        e.Values("insertmonth") = Request.QueryString("month")
        e.Values("insertproject") = Request.QueryString("project")
    End Sub

when I do the insert it tells me that the year field on the table cannot be null
0
 
Carl TawnSystems and Integration DeveloperCommented:
Then that suggests that either the parameter for your query is not called "InsertYear" or QueryString("year") is empty.
0
 
MrTimewalkAuthor Commented:
Got ya, was using the names of the screen fields rather than the database fields, nice one

Many thanks

Owe you one
0
All Courses

From novice to tech pro — start learning today.