自定义数据源时,如何使用gridview 的功能按钮?
// .aspx:
<asp:GridView ID="gv_master" runat="server" AutoGenerateColumns="False"
Width="291px" DataKeyNames="id">
<Columns>
<asp:BoundField DataField="id" HeaderText="ID" />
<asp:BoundField DataField="class" HeaderText="class" />
<asp:BoundField DataField="name" HeaderText="name" />
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>
// .cs
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
gv_master.DataSource = dmGlobal.dtTestProduct();
gv_master.DataBind();
}
}
在表格中按 "edit"按钮后得到如下异常:
The GridView 'gv_master' fired event RowEditing which wasn't handled.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The GridView 'gv_master' fired event RowEditing which wasn't handled.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
但如果使用指定一个 数据源 就没有问题,请赐教