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

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -