c# - how to auto complete textbox in gridview? -
i have gridview textbox columnns, need auto complete textbox in grridview...
my code is,
<table style="width: 700px;"> <tr> <th colspan="3">medicine detail : </th> </tr> <tr> <td colspan="3"> <script type="text/javascript"> $(function () { var availabletags = [ <%= suggestionlist %>]; $("#<%= txtmedname.clientid %>").autocomplete({ source: availabletags }); }); </script> <asp:gridview id="gridview1" runat="server" showfooter="true" autogeneratecolumns="false" width="700px" horizontalalign="center" onrowdeleting="gridview1_rowdeleting"> <columns> <asp:boundfield datafield="rownumber" headertext="s.no" /> <asp:templatefield headertext="medicine name"> <itemtemplate> <asp:textbox id="txtmedname" runat="server" cssclass="textbox"></asp:textbox> </itemtemplate> </asp:templatefield> </columns> </asp:gridview> </td> </tr> <tr> <td colspan="2"> </td> <td> <asp:button id="button7" runat="server" text="add" cssclass="button" onclick="button7_click" /> <asp:button id="button8" runat="server" text="cancel" cssclass="button" postbackurl="~/patiententry.aspx" /> </td> </tr> </table>
my .cs code is,
public string suggestionlist = ""; string querystring = "select * newmedicinemaster"; using (sqlconnection con = new sqlconnection(system.web.configuration.webconfigurationmanager.connectionstrings["hospitalconnection"].connectionstring)) { using (sqlcommand command = new sqlcommand(querystring, con)) { con.open(); using (sqldatareader reader = command.executereader()) { while (reader.read()) { if (string.isnullorempty(suggestionlist)) { suggestionlist += "\"" + reader["medname"].tostring() + "-" + reader["medid"].tostring() + "\""; } else { suggestionlist += ", \"" + reader["medname"].tostring() + "-" + reader["medid"].tostring() + "\""; } } } } }
but error came like,
name 'txtmedname' not exist in current context
<input type="text" values="<%# eval('txtmedname')%>'">
Comments
Post a Comment