Gridview Edit搜索后无法正常工作

时间:2016-05-04 23:04:36

标签: c# asp.net gridview

这是我的搜索事件处理程序。

protected void btnSearch_Click(object sender, EventArgs e)
{
    GridView1.DataSourceID = "";
    GridView1.DataSource = ObjectDataSourceSearch;
    GridView1.DataBind();
}

当我点击编辑搜索结果时,出现此错误:

The GridView 'GridView1' fired event RowEditing which wasn't handled.

请帮帮我。

标记如下:

<asp:GridView ID="GridView1" runat="server" DataKeyNames="Id" AllowSorting="True" AutoGenerateColumns="False" BackColor="Orange" BorderColor="Tan" BorderWidth="1px" CellPadding="3" DataSourceID="SqlDataSource1" GridLines="None" Height="16px" Width="1168px" ForeColor="Black"  OnSelectedIndexChanged="GridView1_SelectedIndexChanged" PageSize="20">
    <AlternatingRowStyle BackColor="white"  />
     <EmptyDataTemplate>
          <div>  
              No Data Available
         </div>
    </EmptyDataTemplate> 
    <Columns>

    <asp:CommandField ShowEditButton="True" ShowSelectButton="True" />
    <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" InsertVisible="False" ReadOnly="True" />
    <asp:BoundField DataField="Name" HeaderText="Name" SortExpression  ="Name"  />
    <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
    <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
    <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
    <asp:BoundField DataField="Source" HeaderText="Source" SortExpression="Source" />
    <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
    <asp:BoundField DataField="JobStatus" HeaderText="JobStatus" SortExpression  ="JobStatus"  />
    <asp:BoundField DataField="Message" HeaderText="Message" SortExpression  ="Message"  />                
    <asp:BoundField DataField="FollowUp" HeaderText="FollowUp" SortExpression="FollowUp" />
    <asp:BoundField DataField="FollowUp2" HeaderText="FollowUp2" SortExpression="FollowUp2" />

2 个答案:

答案 0 :(得分:-1)

此错误,因为您使用道具&#34;行编辑&#34;在cs文件中没有任何实现 您必须从gridview属性中删除此函数

或在cs文件中实现它的方法

protected void GridView1_RowUpdating(object sender,GridViewEditEventArgs e)    {

}

答案 1 :(得分:-2)

请你必须在你的代码中实现RowUpdating事件,比如

protected void GridView1_RowUpdating(object sender, GridViewEditEventArgs e)
   {
 // Write here code for edit Rows 
   }