我在aspx页面中定义了gridview,定义如下: 已在codbehinb中定义了具有以下签名的事件处理程序:
protected void ApplicantGridView_RowUpdating(object sender, GridViewUpdatedEventArgs e)
{
e.NewValues["fk_WorkerID"] = workersDropDownList.SelectedValue;
}
我能够成功构建Web项目,当我在浏览器中打开页面时出现上述错误。
<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;" />
这是aspx格式的gridview
答案 0 :(得分:9)
您的方法签名不正确,应该阅读
protected void ApplicantGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
你有GridViewUpdate * d * EventArgs
答案 1 :(得分:2)
这是事件参数类型
中的一个非常小的差异 RowUpdating 使用GridViewUpdateEventArgs
RowUpdated 使用GridViewUpdatedEventArgs
注意额外的'd'