0

This is my event handler for search.

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

When I click edit for the search results, I get this error:

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

Please help me.

The markup is as follows:

<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" />
MethodMan
  • 18,625
  • 6
  • 34
  • 52
Anoj
  • 117
  • 1
  • 1
  • 15
  • Possible duplicate of [The GridView ' ' fired event RowUpdating which wasn't handled. C# code behind asp.net](http://stackoverflow.com/questions/13016531/the-gridview-fired-event-rowupdating-which-wasnt-handled-c-sharp-code-behi) – MethodMan May 04 '16 at 23:11
  • This is different. I can update the gridview initially but when It comes to the search result, I can't edit that new table( the result from that search) – Anoj May 04 '16 at 23:33
  • you need to show more code perhaps the markup.. – MethodMan May 04 '16 at 23:34
  • I just updated, please take a look! TY in advance – Anoj May 04 '16 at 23:36
  • I would suggest reading this it's pretty much the same thing except the example shows with a delete button http://www.aspsnippets.com/Articles/ASPNet-GridView---Delete-Row-with-Confirmation.aspx you still are not showing all relevant code I don't think – MethodMan May 04 '16 at 23:42
  • I am quite confused about the default functionality of Gridview Edit. When the gridview loads the data, I can edit and update. When I search for particular entries, I bind the result to the Same Gridview but this time, it wont let me Edit( Shows above mentioned error) – Anoj May 05 '16 at 01:39
  • You can take a look at my answer to the following post. You will see which event handlers need to be implemented to allow editing/updating of data records in a GridView: http://stackoverflow.com/questions/36827111/asp-net-gridview-how-to-edit-and-delete-data-records/36828018#36828018. – ConnorsFan May 05 '16 at 01:41
  • Maybe switching from a datasource given by a `DataSourceID` (before search) to another one managed in code-behind (after search) makes things more complicated. Could you choose one of the two methods and use it in all cases? – ConnorsFan May 05 '16 at 01:44

2 Answers2

-1

This error because you use prop "Row Editing " without any implementation in cs file you either have to remove this function from gridview properties

or implement it's method in cs file

protected void GridView1_RowUpdating(object sender, GridViewEditEventArgs e) {

}

prime
  • 331
  • 1
  • 6
  • 17
-2

please you have to implement RowUpdating event in your code like

protected void GridView1_RowUpdating(object sender, GridViewEditEventArgs e)
   {
 // Write here code for edit Rows 
   }
suulisin
  • 1,414
  • 1
  • 10
  • 17