p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Basics (http://p2p.wrox.com/forumdisplay.php?f=136)
-   -   Programatically Change Paramet Of ObjectDataSource (http://p2p.wrox.com/showthread.php?t=60357)

rsearing July 21st, 2007 11:21 PM

Programatically Change Paramet Of ObjectDataSource
I have a GridView that points to an ObjectDataSource.
This ObjectDataSource's update method is:

Public Shared Function Upsert(ByVal myPaintingType As PaintingType) As Integer
    Return PaintingTypeDB.Save(myPaintingType)
End Function

Where myPaintingType is, obviously, my own object that has one field called "url".

My problem is that I have chnaged the "URL" column of the Gridview to a template so that I can change the "editItemTemplate" of URL to have a FileUpload control. I cannot figure out how to programatically change the "url" property of my object to the filename of the fileupload.

(Typically, you would have a textbox that "Binds" to the URL value--but I am deleting the textbox and putting the fileupload)

I have created a "Sub" in the codebehind of the page to try to capture the Gridview1 updating or the ObjectDataSOurce updating functions..but I don't know how to take the filename from the fileupload and put into the object that is being passed to the update method of my business layer.

Please help.

Kind Regards,

rsearing July 22nd, 2007 08:08 AM

I figured it out.

I was tying into the wrong event. I was trying to tie into the ObjectDataSource updating. Well, If you put the following in the GridView's rowupdating--works perfectly...I was able to programatically change the value of my object.

Dim url As String = myFileUpload.FileName
e.NewValues("url") = url


All times are GMT -4. The time now is 01:32 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.