Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Answers
Need urgent help.
radhiga_it
20y
2.3k
1
Reply
im creating a CS page which is retriving data from the Database. along with every row, i want to attache a edit button and i want to attach a eventhandler for that. i tried so much but it is giving error..pls help me.. public class Form1 : System.Web.UI.Page { protected System.Web.UI.WebControls.Button btnedit; public void handleit(object sender,EventArgs e) { Response.Write("handle"); } private void Page_Load(object sender, System.EventArgs e) { if(!IsPostBack) { Response.Write("
"); } } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); this.btnedit.Click += new System.EventHandler(this.handleit); } #endregion } } What is the problem in this. i have been struggling for this for the past four days.. it is giving error that Object reference not set to an instance of an object. 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.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 122: { Line 123: this.Load += new System.EventHandler(this.Page_Load); Line 124: this.btnedit.Click += new System.EventHandler(this.handleit); Line 125: Line 126: }
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Is it possible to register an httpHandler with code?
Session timeout problem in ASP.NEt application when accessed remotely