Solved

Prepopulate a value in detailview during insert

Posted on 2006-11-14
8
321 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 250 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
 

Author Comment

by:MrTimewalk
ID: 17937599
does not populate the values
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now