Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I am calling gridview events in programatically in InitializeComponent()

this.GridView1.RowDataBound += new System.EventHandler(this.GridView1_RowDataBound);

error is No overload for 'DataGrid1_RowDataBound' matches delegate 'System.EventHandler'

Thanks,
Priya
Posted
Updated 28-Oct-15 21:04pm
v3
Comments
Debojyoti Saha 29-Oct-15 2:54am    
Please try this
this.Load += new System.EventHandler(this.Page_Load);
Inc_GridView1.GridRowDataBound +=
new Inc_GridView.RowDataBound(this.DataGrid1_RowDataBound);
Sergey Alexandrovich Kryukov 29-Oct-15 2:56am    
No, you are not calling an event. There is no such concept. You never need it. Please tell us what you want to achieve, and I'll tell you how.
—SA
PriyaVar 29-Oct-15 3:02am    
i want to call this method in InitializeComponent()
private void DataGrid1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{


if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[4].Text = "INCIDENT TITLE";
e.Row.Cells[3].Text = "INCIDENT NUMBER";
e.Row.Cells[2].Text = "INCIDENT ID";

}
e.Row.Cells[1].Visible = false;
}
Krunal Rohit 29-Oct-15 3:13am    
Rather you should call your event after the InitializeComponent(). Because let the gridview initialize first.


-KR

1 solution

You can try by adding GridViewRowEventHandler
this.GRD.RowDataBound += new GridViewRowEventHandler(this.GRD_RowDataBound);

C#
void GRD_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       throw new NotImplementedException();
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900