Simple question? I have a gridview with an insert row in the footer and i have validation controls for that row and the edittemplate how do get it to only validate for that row because when i do an edit it validates the insert row aswell. I just wnat to validate the insert row or edit row.
<asp:GridView ID="PageSettings" runat="server"
AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False"
AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True"
DataKeyNames="Id"
DataSourceID="ObjectDataSourcePages"
OnLoad="PageSettings_Load"
OnRowDataBound="PageSettings_DataBound"
OnRowCommand="PageSettings_RowCommand"
OnRowCreated="PageSettings_RowCreated"
OnRowEditing="PageSettings_RowEditing"
OnRowCancelingEdit="PageSettings_RowCancelingEdit"
OnRowUpdating="PageSettings_RowUpdating"
OnPageIndexChanging="PageSettings_PageIndexChanging"
OnSorting="PageSettings_Sorting"
OnSorted="PageSetting_Sorted"
PageSize="2"
ShowFooter="True"
ShowHeaderWhenEmpty="True">
<Columns>
<asp:TemplateField HeaderText="Page Name" HeaderStyle-HorizontalAlign="Left" SortExpression="Name">
<ItemTemplate>
<%# Eval("Name") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="Name" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="valRequireName" runat="server"
ControlToValidate="Name"
CssClass="gridview-error"
Display="Dynamic"
SetFocusOnError="true">*</asp:RequiredFieldValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="InsertName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="valRequireInsertName" runat="server"
ControlToValidate="InsertName"
Display="Dynamic"
SetFocusOnError="true">*</asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Path" HeaderStyle-HorizontalAlign="Left" SortExpression="Path">
<ItemTemplate>
<%# Eval("Path") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="Path" runat="server" Text='<%# Bind("Path") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="valRequirePath" runat="server"
ControlToValidate="Path"
Display="Dynamic"
SetFocusOnError="true">*</asp:RequiredFieldValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="InsertPath" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="valRequireInsertPath" runat="server"
ControlToValidate="InsertPath"
Display="Dynamic"
SetFocusOnError="true">*</asp:RequiredFieldValidator>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Route Value" HeaderStyle-HorizontalAlign="Left" SortExpression="RouteValue">
<ItemTemplate>
<%# Eval("RouteValue") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="RouteValue" runat="server" Text='<%# Bind("RouteValue") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="InsertRouteValue" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="RegExp" HeaderStyle-HorizontalAlign="Left" SortExpression="RegExp">
<ItemTemplate>
<%# Eval("RegExp") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="RegExp" runat="server" Text='<%# Bind("RegExp") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="InsertRegExp" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
You can use a
Validation Group
Define a separate group for each operation
SaveRecords
&
EditRecords
. You have to specify each validation group on the Save/Edit buttons & all corresponding validation controls to fire them for that event.
MSDN
After a long Time
but you must add in footer requiredfieldvalidator a validationgroup with a unique name and add this validationgroup to add button
Related
I have a checkbox on my griview and its able to be clicked before the edit button is clicked, this doesn't make sense to me and its not something I have came across before. In theory the checkbox should be greyed out until a user clicks the edit button.
Nothing can be updated but it just doesn't make any sense as to why this functionality would be available. I have set up Gridviews before using checkboxes and never came across this. Below is my code:
<asp:GridView ID="gvLeagues" runat="server"
AutoGenerateColumns="False"
onpageindexchanging="gvLeagues_PageIndexChanging"
onrowcancelingedit="gvLeagues_RowCancelingEdit"
onrowdatabound="gvLeagues_RowDataBound"
onrowediting="gvLeagues_RowEditing"
onrowupdating="gvLeagues_RowUpdating"
onsorting="gvLeagues_Sorting" EnableModelValidation="True"
CssClass="footable"
EditRowStyle-CssClass="table table-bordered" >
No Data Found.
<asp:TemplateField HeaderText="Name" SortExpression="Name">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Name")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate><asp:Label ID="Label1" runat="server" Text='<%# Bind("Name")%>'></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Created Date" SortExpression="CreatedDate">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" ReadOnly="true" Text='<%# Bind("CreatedDate")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate><asp:Label ID="Label2" runat="server" Text='<%# Bind("CreatedDate")%>'></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Day" SortExpression="Day">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Day")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate><asp:Label ID="Label3" runat="server" Text='<%# Bind("Day")%>'></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Season" SortExpression="Season">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Season")%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate><asp:Label ID="Label4" runat="server" Text='<%# Bind("Season")%>'></asp:Label></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Enabled" SortExpression="Enabled">
<EditItemTemplate>
<asp:CheckBox ID="chkEnabled" runat="server" Checked='<%# Eval("Enabled")%>' />
</EditItemTemplate>
<ItemTemplate><asp:CheckBox ID="chkEnabled" runat="server" Checked='<%# Eval("Enabled")%>' /></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
When using the ItemTemplate, you are the one specifying what and how you want to see it. Just set that checkbox as disabled.
<asp:TemplateField HeaderText="Enabled" SortExpression="Enabled">
<EditItemTemplate>
<asp:CheckBox ID="chkEnabled" runat="server" Checked='<%# Eval("Enabled")%>' />
</EditItemTemplate>
<ItemTemplate><asp:CheckBox ID="chkEnabled" runat="server" Checked='<%# Eval("Enabled")%>' enabled="False"/></ItemTemplate>
</asp:TemplateField>
I have a web application written in VS2010.
I have a GridView in which I want to add 2 different validations to a field in edit mode. One validation is that it is a required field. The other validation is a max. length of 80 characters.
Below is my HTML:
<asp:GridView ID="UserInfoGridView" runat="server" AutoGenerateColumns="False"
Caption="User Information" CaptionAlign="Top" CssClass="grid" HorizontalAlign="Left"
PageSize="1" Width="400px" ShowHeaderWhenEmpty="true" Height="60px"
OnRowCancelingEdit="UserInfoGridView_RowCancelingEdit"
OnRowEditing="UserInfoGridView_RowEditing"
OnRowUpdating="UserInfoGridView_RowUpdating">
<Columns>
<asp:TemplateField HeaderText="Name" ItemStyle-Wrap="false">
<EditItemTemplate>
<asp:TextBox ID="uigvTxtBoxName" runat="server" Text='<%# Bind("UserName") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldEditName" ControlToValidate="uigvTxtBoxName" runat="server"
ErrorMessage="Required field." ValidationGroup="EditUserNameValidation" Display="Dynamic"
CssClass="message-error">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="MaxValEditName" ControlToValidate="uigvTxtBoxName" runat="server"
ErrorMessage="Maximum length is 80." ValidationGroup="EditUserNameValidation" Display="Dynamic"
CssClass="message-error" ValidationExpression="^.{1,80}$">
</asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="uigvLblName" runat="server" Text='<%# Bind("UserName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Email Address" ItemStyle-Wrap="false">
<EditItemTemplate>
<asp:TextBox ID="uigvTxtBoxEmail" runat="server" Text='<%# Bind("UserEmail") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldEditEmail" ControlToValidate="uigvTxtBoxEmail" runat="server"
ErrorMessage="Required field." ValidationGroup="EditUserEmailValidation" Display="Dynamic" CssClass="message-error">
</asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="MaxValEditEmail" ControlToValidate="uigvTxtBoxEmail" runat="server"
ErrorMessage="Maximumn length is 80." ValidationGroup="EditUserEmailValidation" Display="Dynamic" CssClass="message-error"
ValidationExpression="^.{1,80}$" >
</asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="uigvLblEmail" runat="server" Text='<%# Bind("UserEmail") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Action" ShowHeader="False" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="Center">
<EditItemTemplate>
<asp:Button ID="uigvUpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="Update" CssClass="gridActionbutton"></asp:Button>
<asp:Button ID="uigvCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
Text="Cancel" CssClass="gridActionbutton"></asp:Button>
</EditItemTemplate>
<ItemTemplate>
<asp:Button ID="uigvEditButton" runat="server" CausesValidation="False" CommandName="Edit"
Text="Edit" CssClass="gridActionbutton">
</asp:Button>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle Wrap="True" />
</asp:GridView>
When in edit mode if the field is left blank, both of the error messages are displayed. If the user enters more than 80 characters, neither message is displayed.
I did this in an application using VS 2012. Can this be done in VS2010? If so, where am I going wrong?
Thanks.
use regularexpression validator or range validator instead of requiredfield validator for validating max length.
So you need to use one required field and the other is regular expression validator.
Here is the gridview part. Somebody please help me to find the answer. I want to multiply Count and Price and display the sum in Amount.
<asp:TemplateField HeaderText="Price">
<ItemTemplate>
<asp:Label ID="lblCardPrice" runat="server" Text='<%# Bind("Price")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Count" >
<ItemTemplate>
<asp:Label ID="lblCount" runat="server" Text='<%# Bind("Count")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount">
<ItemTemplate>
<asp:Label ID="lblAmount" runat="server" Text='<%# Eval("(Amount)")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
try this:
<asp:TemplateField HeaderText="Amount" >
<ItemTemplate >
<asp:Label ID="lblAmount" runat="server" Text='<%# Convert.ToInt32(Eval("Count"))*Convert.ToInt32(Eval("Price"))%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
I have GridView:
<asp:GridView ID="MyGridView" runat="server" ShowFooter="true"
AutoGenerateColumns="False" Visible="True">
<Columns>
<asp:BoundField DataField="id" ItemStyle-HorizontalAlign="center"/>
<asp:BoundField DataField="fullName" />
<asp:TemplateField HeaderText="situation>">
<ItemTemplate>
<asp:DropDownList ID="dl_situation" runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="tbNr" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Data">
<ItemTemplate>
<asp:TextBox ID="tbDate" runat="server"></asp:TextBox>
</asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
It work fine, but when I add RegularrExpressionValidator for textbox with id="tbDate" mygrid does not work
This regular expression must accept datetime in format "dd.MM.yyyy"
<asp:GridView ID="MyGridView" runat="server" ShowFooter="true"
AutoGenerateColumns="False" Visible="True">
<Columns>
<asp:BoundField DataField="id" ItemStyle-HorizontalAlign="center"/>
<asp:BoundField DataField="fullName" />
<asp:TemplateField HeaderText="situation>">
<ItemTemplate>
<asp:DropDownList ID="dl_situation" runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="tbNr" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Data">
<ItemTemplate>
<asp:TextBox ID="tbDate" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularCert" runat="server"
ControlToValidate="tbDate" ErrorMessage="Incorect Data"
ValidationExpression=
"(0[1-9]|[12][0-9]|3[01])[-.](0[1-9]|1[012])[-.](19|20)[0-9]{2}"
Display="Dynamic"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="*" ControlToValidate="tbDate">
</asp:RequiredFieldValidator>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
I think you typed "tbData" instead of "tbDate" in the ControlToValidate property
<asp:RegularExpressionValidator ID="RegularCert" runat="server"
ControlToValidate="tbDate" ErrorMessage="Incorect Data" ValidationExpression= "(0[1-9]|[12][0-9]|3[01])[-.](0[1-9]|1[012])[-.](19|20)[0-9]{2}"
Display="Dynamic"></asp:RegularExpressionValidator>
I changed ClientIDMode to Predictable for TextBox, RegularExpressionValidator and RequiredFieldValidator and began to work
change ControlToValidate="tbData" to ControlToValidate="tbDate" for <asp:RegularExpressionValidator
Have you tried placing the <asp:RegularExpressionValidator ...> inside the
<ItemTemplate>
<asp:TextBox ID="tbDate" runat="server"></asp:TextBox>
</ItemTemplate>
also you need to indicate some text to display if it fails the regex validation
actually what Hallie said is more than likely the answer ha
How do I get the old values in a gridview row in the row_updating event?
I'm using a sqldatasource control to populate the grid and want to write the update code in the RowUpdating event.
There are 10 fields displayed in the grid.
I can get the value of the first field using
string old_Category = e.OldValues[0].ToString();.
But it doesn't work for index items greater than 0. This doesn't work
string old_Category = e.OldValues[1].ToString();
it returns an error message
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
even though there are 10 columns in the grid.
========================================
Here's the gridview markup
<asp:GridView
ID="GridView1"
runat="server"
AutoGenerateColumns="False"
DataSourceID="SqlDataSource1"
BorderWidth="0px"
BorderStyle="None"
Width="100%"
CellPadding="2"
PageSize="25"
OnRowDeleting="ProjectListGridView_RowDeleting"
onrowdatabound="GridView1_RowDataBound"
onrowupdating="GridView1_RowUpdating" onrowediting="GridView1_RowEditing" >
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:TemplateField HeaderText="WeekEnding" SortExpression="WeekEnding">
<ItemTemplate>
<asp:Label ID="lblWeekEnding" runat="server" Text='<%# Bind("WeekEnding") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Project" SortExpression="Project">
<EditItemTemplate>
<asp:DropDownList
ID="DropDownList1"
runat="server"
DataSourceID="sdsDdlProjectsEdit"
DataTextField="ProjectName"
DataValueField="ProjectID"
AutoPostBack="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged"
>
</asp:DropDownList>
<asp:SqlDataSource
ID="sdsDdlProjectsEdit"
runat="server"
ConnectionString="<%$ ConnectionStrings:ttuser %>"
SelectCommand="SELECT ProjectID,ProjectName FROM dbo.aspnet_starterkits_Projects">
</asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Project") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Category" SortExpression="Category">
<EditItemTemplate>
<asp:DropDownList
ID="DropDownList2"
runat="server"
DataSourceID="sdsDDL2"
DataTextField="CategoryName"
DataValueField="CategoryID">
</asp:DropDownList>
<asp:SqlDataSource
runat="server"
ID="sdsDDL2"
ConnectionString="<%$ ConnectionStrings:ttuser %>"
SelectCommand="SELECT [CategoryID], [CategoryName],[ProjectID] FROM dbo.aspnet_starterkits_ProjectCategories WHERE ([ProjectID]=#ProjectID)">
<SelectParameters>
<asp:Parameter Name="ProjectID" />
</SelectParameters>
</asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Category") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sun" SortExpression="Sun">
<EditItemTemplate>
<asp:TextBox ID="txtSunEdit" runat="server" Text='<%# Eval("Sun") %>' Columns="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblSun" runat="server" Text='<%# Bind("Sun") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Mon" SortExpression="Mon">
<EditItemTemplate>
<asp:TextBox ID="txtMonEdit" runat="server" Text='<%# Eval("Mon") %>' Columns="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Mon") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Tue" SortExpression="Tue">
<EditItemTemplate>
<asp:TextBox ID="txtTueEdit" runat="server" Text='<%# Eval("Tue") %>' Columns="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("Tue") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Wed" SortExpression="Wed">
<EditItemTemplate>
<asp:TextBox ID="txtWedEdit" runat="server" Text='<%# Eval("Wed") %>' Columns="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Wed") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Thu" SortExpression="Thu">
<EditItemTemplate>
<asp:TextBox ID="txtThuEdit" runat="server" Text='<%# Eval("Thu") %>' Columns="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("Thu") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Fri" SortExpression="Fri">
<EditItemTemplate>
<asp:TextBox ID="txtFriEdit" runat="server" Text='<%# Eval("Fri") %>' Columns="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("Fri") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sat" SortExpression="Sat">
<EditItemTemplate>
<asp:TextBox ID="txtSatEdit" runat="server" Text='<%# Eval("Sat") %>' Columns="2"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("Sat") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
and here is the sqldatasource
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ttuser %>"
SelectCommand="SELECT
#WeekEnding WeekEnding
,Project
,ProjectID
,Category
,CategoryID
,isnull([1], 0) Sun
,isnull([2], 0) Mon
,isnull([3], 0) Tue
,isnull([4], 0) Wed
,isnull([5], 0) Thu
,isnull([6], 0) Fri
,isnull([7], 0) Sat
from
(select P.ProjectName Project,P.ProjectID, CAT.CategoryName Category,CAT.CategoryID, Datepart(dw, TE.TimeEntryDate) DOW, TE.TimeEntryDuration Hours
FROM
dbo.aspnet_starterkits_TimeEntry TE inner join
dbo.aspnet_starterkits_ProjectCategories CAT on
TE.CategoryID=CAT.CategoryID inner join
dbo.aspnet_starterkits_Projects P on
CAT.ProjectID=P.ProjectID
Where (TE.TimeEntryDate between dateadd(dd, -6, #WeekEnding) and #WeekEnding) AND
TE.TimeEntryUserID=(SELECT UserId FROM dbo.aspnet_Users WHERE UserName=#UserName)) Source
pivot (max(Hours)for DOW in ([1],[2],[3],[4],[5],[6],[7]) ) as pvt" OldValuesParameterFormatString="original_{0}"
<SelectParameters>
<asp:ControlParameter ControlID="WeekEnding2" Name="WeekEnding"
PropertyName="Text" />
<asp:ControlParameter ControlID="UserList" Name="UserName"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
Just set Enableviewstate property to false of gridview you can get new value
Reference:
http://www.codeproject.com/Questions/139076/not-getting-new-entered-values-on-grid-view-row-up
Just a long shot really. Have you tried setting the DataKeyNames property?
<asp:gridview id="GridView1"
...
DataKeyNames="ProjectID"
/>
From msdn
Use the OldValues property
(dictionary) to access the original
values of the fields in the row to
update. This dictionary contains all
fields in the row except the key
fields. The key fields are defined in
the DataKeyNames property of a
GridView control.