Actually--it didn't..not only did it work, but it used the value and not the one from the newvalues I added. NOW..a couple things I did since pasting
a) I noticed that I don't actually have a binding "title" in here which makes me wonder how the title was actually updating. If you look at the line I added in the code behind--like you suggested..it didn't actually change the title to new value-it actually pulled the value from the edit field.
b) Now, when I did change to a field that is in the page (URL) it actually did assign the value "New Value" to URL--but that contradicts what you said in the reply above that it wouldn't allow to insert a duplicate "newvalue"
Here is my page:
<%@ Page Language="
VB" MasterPageFile="~/Admin/AdminMasterPage.master" AutoEventWireup="false" CodeFile="editpictures.aspx.
vb" Inherits="Admin_editpictures" title="Edit Picture" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<div style="padding-top:15px; margin-left:15px">
<div style="font-size:1.5em; text-align:center;">
<asp:Label ID="titleLabel" Font-Bold="true" Font-Underline="true" runat="server" ></asp:Label>
</div>
<div style="padding-left:200px; margin-top:10px; padding-bottom:10px">
<asp:DetailsView CssClass="MyView" ID="DetailsView1" runat="server" Height="50px" Width="350px" AllowPaging="True" AutoGenerateRows="False" DataSourceID="ObjectDataSource1" DataKeyNames="paintingID,url" >
<Fields>
<asp:TemplateField SortExpression="URL" ShowHeader="False">
<EditItemTemplate>
<span style="color:Blue; font-weight:bold"> Old File: </span>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("URL") %>'></asp:Label><br />
<span style="color:Blue; font-weight:bold;">New File: </span>
<asp:FileUpload ID="FileUpload1" runat="server" />
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("URL") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Image ID="Image1" BorderColor="Black" BorderStyle="Solid" BorderWidth="2px" runat="server" ImageUrl='<%# Eval("URL", "~/Paintings/{0}") %>' Width="60px" /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Size" HeaderText="Size" SortExpression="Size" />
<asp:TemplateField HeaderText="Ptype" SortExpression="Ptype" >
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" OnDatabound = "DropDownList1_DataBound" DataSourceID="ObjectDataSource2" DataTextField="PaintType" DataValueField="PaintTypeID" SelectedValue='<%# Bind("Ptype") %>' >
</asp:DropDownList>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetPaintingTypeList" TypeName="Searing.SunArtSite.Bll.PaintingTypeManag er"></asp:ObjectDataSource>
</EditItemTemplate>
<InsertItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" OnDatabound = "DropDownList1_DataBound" DataSourceID="ObjectDataSource2" DataTextField="PaintType" DataValueField="PaintTypeID" SelectedValue='<%# Bind("Ptype") %>' >
</asp:DropDownList>
<asp:ObjectDataSource ID="ObjectDataSource2" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetPaintingTypeList" TypeName="Searing.SunArtSite.Bll.PaintingTypeManag er"></asp:ObjectDataSource>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Ptype") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Value" HeaderText="Value" SortExpression="Value" />
<asp:TemplateField HeaderText="Comments" SortExpression="Comments">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Comments") %>' Height="200px" TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Comments") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Comments") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:CheckBoxField DataField="PrintAvail" HeaderText="PrintAvail" SortExpression="PrintAvail" />
<asp:CheckBoxField DataField="NotecardAvail" HeaderText="NotecardAvail" SortExpression="NotecardAvail" />
<asp:CommandField ShowEditButton="True" ShowDeleteButton="True" />
</Fields>
</asp:DetailsView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetPaintingList" TypeName="Searing.SunArtSite.Bll.PaintingManager" DataObjectTypeName="Searing.SunArtSite.BO.Painting " InsertMethod="Upsert" UpdateMethod="Upsert" DeleteMethod="DeletePainting">
<SelectParameters>
<asp:QueryStringParameter Name="id" QueryStringField="id" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:Label ID="FileUploadReport" runat="server" ></asp:Label>
</div>
</div>
</asp:Content>
Here is my code behind:
Imports System.IO
Partial Class Admin_editpictures
Inherits System.Web.UI.Page
Protected Sub DropDownList1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs)
Dim myDropDownList As DropDownList
myDropDownList = CType(DetailsView1.FindControl("DropDownList1"), DropDownList)
'myDropDownList.Items.Insert(0, "Note Cards")
'myDropDownList.Items.Insert(1, "Prints")
' myDropDownList.Items(0).Value = 1
'myDropDownList.Items(1).Value = 2
End Sub
Protected Sub DetailsView1_ItemDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewDeleteEventAr gs) Handles DetailsView1.ItemDeleting
Dim fileName As String = e.Keys(1).ToString
File.Delete(MapPath("~/Paintings/") & fileName)
End Sub
Protected Sub DetailsView1_ItemInserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertEventAr gs) Handles DetailsView1.ItemInserting
Dim myDropDownList As DropDownList
myDropDownList = CType(DetailsView1.FindControl("DropDownList1"), DropDownList)
e.Values.Insert(e.CommandArgument, "ptype", myDropDownList.SelectedValue)
End Sub
Protected Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdateEventAr gs) Handles DetailsView1.ItemUpdating
Dim myDropDownList As DropDownList
myDropDownList = CType(DetailsView1.FindControl("DropDownList1"), DropDownList)
'e.NewValues.Insert(e.CommandArgument, "ptype", myDropDownList.SelectedValue)
e.NewValues("ptype") = myDropDownList.SelectedValue
e.NewValues.Insert(e.CommandArgument, "title", "newvalue")
Dim myFileUpload As FileUpload
Dim oldFileName As String = CType(DetailsView1.FindControl("Label3"), Label).Text
myFileUpload = CType(DetailsView1.FindControl("FileUpload1"), FileUpload)
If myFileUpload.HasFile Then
Try
File.Delete(MapPath("~/Paintings/") & oldFileName)
myFileUpload.SaveAs(Server.MapPath("~/Paintings/" & myFileUpload.FileName))
Dim url As String = myFileUpload.FileName
If (url = String.Empty) Then
url = oldFileName
End If
e.NewValues("url") = myFileUpload.FileName
Catch ex As Exception
FileUploadReport.Text = "Failed because: <br/>" & ex.Message
End Try
End If
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
titleLabel.Text = Request.QueryString("name")
End Sub
End Class