So, two pages: first one is a simple datasource & gridview with edit button, is working. Second is the same code but then in a contentplaceholder page, linked to a masterpage. Now the code is not working, when editing, it returns empty fields in steds of edited fields.

<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="AllCP.aspx.vb" Inherits="Pages_AllCP" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlace" Runat="Server">
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataKeyNames="cp_id" DataSourceID="ObjectDataSource1">
            <Columns>
                <asp:CommandField ShowEditButton="True" />
                <asp:BoundField DataField="cp_id" HeaderText="cp_id" InsertVisible="False" 
                    ReadOnly="True" SortExpression="cp_id" />
                <asp:BoundField DataField="voornaam" HeaderText="voornaam" 
                    SortExpression="voornaam" />
                <asp:BoundField DataField="achternaam" HeaderText="achternaam" 
                    SortExpression="achternaam" />
                <asp:BoundField DataField="tussenvoegsel" HeaderText="tussenvoegsel" 
                    SortExpression="tussenvoegsel" />
                <asp:BoundField DataField="initialen" HeaderText="initialen" 
                    SortExpression="initialen" />
                <asp:BoundField DataField="geslacht" HeaderText="geslacht" 
                    SortExpression="geslacht" />
                <asp:BoundField DataField="functie" HeaderText="functie" 
                    SortExpression="functie" />
                <asp:BoundField DataField="telefoon" HeaderText="telefoon" 
                    SortExpression="telefoon" />
                <asp:BoundField DataField="email" HeaderText="email" SortExpression="email" />
                <asp:BoundField DataField="bijzonderheden" HeaderText="bijzonderheden" 
                    SortExpression="bijzonderheden" />
                <asp:BoundField DataField="ingevoerd_door" HeaderText="ingevoerd_door" 
                    SortExpression="ingevoerd_door" />
                <asp:BoundField DataField="datum_invoer" HeaderText="datum_invoer" 
                    SortExpression="datum_invoer" />
                <asp:BoundField DataField="gewijzigd_door" HeaderText="gewijzigd_door" 
                    SortExpression="gewijzigd_door" />
                <asp:BoundField DataField="datum_wijzig" HeaderText="datum_wijzig" 
                    SortExpression="datum_wijzig" />
                <asp:CheckBoxField DataField="inactief" HeaderText="inactief" 
                    SortExpression="inactief" />
            </Columns>
        </asp:GridView>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetCP" 
            TypeName="SVSTableAdapters.CPTableAdapter" UpdateMethod="Update">
            <UpdateParameters>
                <asp:Parameter Name="voornaam" Type="String" />
                <asp:Parameter Name="achternaam" Type="String" />
                <asp:Parameter Name="tussenvoegsel" Type="String" />
                <asp:Parameter Name="initialen" Type="String" />
                <asp:Parameter Name="geslacht" Type="String" />
                <asp:Parameter Name="functie" Type="String" />
                <asp:Parameter Name="telefoon" Type="String" />
                <asp:Parameter Name="email" Type="String" />
                <asp:Parameter Name="bijzonderheden" Type="String" />
                <asp:Parameter Name="ingevoerd_door" Type="Int32" />
                <asp:Parameter Name="datum_invoer" Type="DateTime" />
                <asp:Parameter Name="gewijzigd_door" Type="Int32" />
                <asp:Parameter Name="datum_wijzig" Type="DateTime" />
                <asp:Parameter Name="inactief" Type="Boolean" />
                <asp:Parameter Name="Original_cp_id" Type="Int32" />
            </UpdateParameters>
        </asp:ObjectDataSource>
</asp:Content>

The masterpage looks like this:

<%@ Master Language="VB"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>

</head>
<body>
    <form id="form1" runat="server">
    <div>
    	<div id="logo">
		    <h1><a href="#">Website naam</a></h1>
		    <p><em>Subtitel van de website</em></p>
	    </div>
	    <hr />
	<!-- end #logo -->
	    <div id="header">
       
          	<div id="search">
			    <form method="get" action="">
				    <fieldset>
				        <input type="text" name="s" id="search-text" size="15" />
				        <input type="submit" id="search-submit" value="GO" />
				    </fieldset>
			    </form>
		    </div>
		    <!-- end #search -->
            <div id="page">
		<asp:ContentPlaceHolder ID ="ContentPlace" runat="server">
        
           </asp:ContentPlaceHolder>
     
	</div>
	<!-- end #page -->

    </div>
    </form>
</body>
</html>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            gridview1.databind()
        End If

    End Sub

try this. I was having issues with my masterpage the other day because of not rebinding the control. Let me know how that works for you.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            gridview1.databind()
        End If

    End Sub

try this. I was having issues with my masterpage the other day because of not rebinding the control. Let me know how that works for you.

The problem was that in the masterpage I had a second <form> tag, (used some CSS style that was in HTML). After deleting this form tag, the editing worked fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.