c# - Call Javascript from GridView TemplateField -
i have gridview, have coded below
<asp:templatefield headertext="item"> <itemtemplate> <asp:button id="btnitem" onclientclick="javascript:searchreqsult(<%#eval("id") %>);" cssclass="save" runat="server" /> </itemtemplate> </asp:templatefield>
i face run time error says button control formatted correctly suppose issue following
onclientclick="javascript:searchreqsult(<%#eval("id") %>);"
any idea?
try following code
protected void gridview1_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.datarow) { button btn = (button)e.row.findcontrol("btnitem"); btn.attributes.add("onclick","searchreqsult(this.id);"); } }
Comments
Post a Comment