Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Prepopulate a value in detailview during insert

Posted on 2006-11-14
8
Medium Priority
?
332 Views
Last Modified: 2012-05-05
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?
0
Comment
Question by:MrTimewalk
  • 4
  • 4
8 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 1000 total points
ID: 17937442
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
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 17937444
You may, of course, need to cast your QueryString value to the correct type for the column.
0
 

Author Comment

by:MrTimewalk
ID: 17937583
DOESN'T WORK
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:MrTimewalk
ID: 17937599
does not populate the values
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 17937925
Are you getting any errors ? How are you populating the data ? Are you bound to a DataSource ?
0
 

Author Comment

by:MrTimewalk
ID: 17938072
   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
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 17938292
Then that suggests that either the parameter for your query is not called "InsertYear" or QueryString("year") is empty.
0
 

Author Comment

by:MrTimewalk
ID: 17938380
Got ya, was using the names of the screen fields rather than the database fields, nice one

Many thanks

Owe you one
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question