The "enableEventValidation" feauture is new for .Net 2.0
When I had a page that called back to itself through the use of a pushbutton, I recieved an error stating:
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@. Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
I went into my web.config file and inserted the following as suggested by microsoft:
<system.web>
 <pages enableEventValidation="true" />
</system.web>
Now the error has gone away, however, the whole point of this particular page is to allow me to edit a row in a datagrid. When I click on the edit button, the page is called back to itself but I the chosen row (and none of the page for that matter) is availible to be edited.
Any ideas on what I am doing wrong? I want to call back the page so that I can edit the row that I chose by clicking on that row's "edit" button.
Here is the actual code from my page:
<%@. Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@. Register TagPrefix="MM" Namespace="DreamweaverCtrls" Assembly="DreamweaverCtrls,version=1.0.0.0,publicKeyToken=836f606ede05d46a,culture=neutral" %>
<MM:DataSet 
id="dsParts"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_PartsAreUs"] %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_PartsAreUs"] %>'
CommandText='<%# "SELECT * FROM dbo.Parts" %>'
Debug="true"
>
 <EditOps>
 <EditOpsTable Name="dbo.Parts" /> 
 <Parameter Name="Name" Type="VarChar" /> 
 <Parameter Name="Description" Type="NVarChar" /> 
 <Parameter Name="Price" Type="Money" /> 
 <Parameter Name="PartID" Type="Int" IsPrimary="true" /> 
 </EditOps>
</MM:DataSet>
<MM:PageBind runat="server" PostBackBind="true" />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<form runat="server">
 <asp:DataGrid id="dgParts" 
 runat="server" 
 AllowSorting="False" 
 AutoGenerateColumns="false" 
 CellPadding="3" 
 CellSpacing="0" 
 ShowFooter="false" 
 ShowHeader="true" 
 DataSource="<%# dsParts.DefaultView %>" 
 PagerStyle-Mode="NextPrev" 
 DataKeyField="PartID"
 onCancelCommand="dsParts.OnDataGridCancel" 
 onEditCommand="dsParts.OnDataGridEdit" 
 onUpdateCommand="dsParts.OnDataGridUpdate" 
 onItemDataBound="dsParts.OnDataGridItemDataBound" 
>
 <HeaderStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />
 <ItemStyle BackColor="#F2F2F2" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
 <AlternatingItemStyle BackColor="#E5E5E5" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
 <FooterStyle HorizontalAlign="center" BackColor="#E8EBFD" ForeColor="#3D3DB6" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Bold="true" Font-Size="smaller" />
 <PagerStyle BackColor="white" Font-Name="Verdana, Arial, Helvetica, sans-serif" Font-Size="smaller" />
 <Columns>
 <asp:EditCommandColumn 
 ButtonType="PushButton" 
 CancelText="Cancel" 
 EditText="Edit" 
 HeaderText="Edit" 
 UpdateText="Update" 
 Visible="True"/>
 <asp:BoundColumn DataField="PartID" 
 HeaderText="PartID" 
 ReadOnly="true" 
 Visible="True"/>
 <asp:BoundColumn DataField="Name" 
 HeaderText="Name" 
 ReadOnly="false" 
 Visible="True"/>
 <asp:BoundColumn DataField="Description" 
 HeaderText="Description" 
 ReadOnly="false" 
 Visible="True"/>
 <asp:BoundColumn DataField="Price" 
 HeaderText="Price" 
 ReadOnly="false" 
 Visible="True"/>
 </Columns>
 </asp:DataGrid>
</form>
</body>
</html>
Check here:
http://aspalliance.com/146_Editing_a_DataGrid_Control
Buck Woody
 
No comments:
Post a Comment