Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate Insert Fields of DetailsView with values of last record

Status
Not open for further replies.

jdemmi

MIS
Jun 6, 2001
1,106
US
VB/asp.Net

I have a detailsview object grabbing data from a data base.

I am able to edit and insert rows fine.

But, on insert all my fields are blank.

I am able to populate them with "hard coded" default values via the databound event handler

Like...
Dim Cal2 As New Calendar
Cal2 = DetailsView1.FindControl("Calendar2")
Cal2.SelectedDate = "12/10/2010

And that works fine.

But, what I need to do is set that value to the value in this cell in the last row of the detailsview.

Does that make sense? Is this possible?

I'm stuck...

-- Jason
"It's Just Ones and Zeros
 
A detailsView only has one row correct? Do you want to set the calendar to display a date that you are binding to detailsView?
 
No, the detailsview has many rows.

But I figured out a way.

On the detailsview bound event I check to see if the mode is insert. If so, I fire another sql query that selects the columns from the "last" (max) record. I then open a datareader and set the field names = to the datareader item

clunky perhaps...but it works.

-- Jason
"It's Just Ones and Zeros
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top