views:

19

answers:

2

Hi all,

I'm having a strange issue with getting my GridView - RowDataBound method to compile. I've got a simple GridView with the following:

<asp:GridView ID="gv_View_Documents" runat="server" AllowSorting="true" 
  DataKeyNames="DocumentName,Description" AutoGenerateColumns="false" 
  OnSorting="gv_View_Documents_Sorting" OnRowCancelingEdit="gv_View_Documents_RowCancelingEdit"  
  OnRowDataBound="gv_View_Documents_RowDataBound" OnRowEditing="gv_View_Documents_RowEditing" 
  OnRowUpdating="gv_View_Documents_RowUpdating">

When I compile, it shows an error shown below.

Compiler Error Message: CS0123: No overload for 'gv_View_Documents_RowDataBound' matches delegate 'System.Web.UI.WebControls.GridViewRowEventHandler'

I have a similar setup for another grid view with no compile issues.

Any ideas? I'm working with C# and ASP.NET

+1  A: 

Most probably your event handler method signature does not match with GridViewRowEventHandler signature i.e.

public delegate void GridViewRowEventHandler(
    Object sender,
    GridViewRowEventArgs e
)

Most probably, you may have used EventArgs as a parameter in your event handler.

VinayC
yes, i am using eventargs as a parameter. how can i solve this. i have another similar grid view. there is no compilation error with that.
Shameer
@Shameer, your event handler signature is wrong. It should be protected void gv_View_Documents_RowDataBound(object sender, GridViewRowEventArgs e) { } - note you are using GridViewCommandEventArgs instead.
VinayC
Thank you for notifying me that. my problem is solved
Shameer
+1  A: 

I think that you dont have a method (in a code behind) with params: Object sender, GridViewRowEventArgs e

 void gv_View_Documents_RowDataBound(Object sender, GridViewRowEventArgs e)
  {
  }
Sebastian Brózda
i already have such a code behind function -> protected void gv_View_Documents_RowDataBound(object sender, GridViewCommandEventArgs e) { }
Shameer
thank u . your answer also helped me
Shameer