I have a gridview defined in aspx page as defined below: have defined event handler in codbehinb with the following signature:
protected void ApplicantGridView_RowUpdating(object sender, GridViewUpdatedEventArgs e)
{
e.NewValues["fk_WorkerID"] = workersDropDownList.SelectedValue;
}
I am able to build the web project sucessfully, when I open the page in the browser i get the above error.
<asp:GridView ID="ApplicantGridView" runat="server" AutoGenerateColumns="False"
DataSourceID="ApplicantsObjectDataSource" DataKeyNames="ApplicantID"
OnRowUpdating="ApplicantGridView_RowUpdating" >
<Columns>
<asp:CommandField ShowEditButton="true" ShowDeleteButton="true" ItemStyle-VerticalAlign="Top">
<ItemStyle VerticalAlign="Top"></ItemStyle>
</asp:CommandField>
<asp:DynamicField DataField="CaseName" HeaderText="Case Name" SortExpression="CaseName"
ItemStyle-VerticalAlign="Top">
<ItemStyle VerticalAlign="Top"></ItemStyle>
</asp:DynamicField>
<asp:DynamicField DataField="CaseNumber" HeaderText="Case Number" SortExpression="CaseNumber"
ItemStyle-VerticalAlign="Top">
<ItemStyle VerticalAlign="Top"></ItemStyle>
</asp:DynamicField>
<asp:DynamicField DataField="ApplicationDate" HeaderText="Application Date" SortExpression="ApplicationDate"
ItemStyle-VerticalAlign="Top">
<ItemStyle VerticalAlign="Top"></ItemStyle>
</asp:DynamicField>
<asp:TemplateField HeaderText="Worker" SortExpression="FS_Worker.WorkerName">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("FSWorker.WorkerName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:ObjectDataSource ID="FSWorkersObjectDataSource" runat="server"
TypeName="DSS_OTDA_FS.DAL.SCDSS_ApplicationRepository"
DataObjectTypeName="DSS_OTDA_FS.DAL.FSWorker"
SelectMethod="GetFSWorkerNames" >
</asp:ObjectDataSource>
<asp:DropDownList ID="FSWorkerDropDownList" runat="server"
DataSourceID="FSWorkerObjectDataSource"
SelectedValue='<%# Eval("WorkerName") %>'
DataTextField="WorkerName" DataValueField="WorkerID"
OnInit="FSWorkersDropDownList_Init" >
</asp:DropDownList>
</EditItemTemplate>
<ItemStyle VerticalAlign="Top" />
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:ValidationSummary ID="ApplicantsValidationSummary" runat="server"
ShowSummary="true" DisplayMode="BulletList" style="color: Red; width: 40em;" />
That is the gridview in the aspx form
Your method signature is incorrect it should read
protected void ApplicantGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
you have GridViewUpdate*d*EventArgs
This is a very small difference in the event arguments type
RowUpdating uses GridViewUpdateEventArgs
RowUpdated uses GridViewUpdatedEventArgs
Notice the extra 'd'