I am creating a custom control by inheriting the Gridview
In the "rendercontents" method, I gave like below,
Issues:Code:protected void btn_Click() { SqlConnection conn = new SqlConnection(ConnectionString); SqlCommand cmd = new SqlCommand(InsertText, conn); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); this.DataBind(); this.ShowAddButton(); } protected override void RenderContents(HtmlTextWriter output) { base.RenderContents(output); StringBuilder sb = new StringBuilder(); sb.Append("<asp:Button ID='btn' runat='server' Text='Addnew' onClick=btn_Click/>"); output.Write(sb.ToString()); }
1. It won't display the button in the output screen
2. If I use <input type=Button value ='add' onClick='btn_click'> (html button) instead of asp.net servercontrol, in the above coding, it won't call the btn_click, which reside in the custom control's one of the procedure.
How to solve the above problem? help needed




Reply With Quote