c# - ASP.NET: How to create a search function just using a textbox? -


i have suggestions regards having search function in website. find registered customers easier admin specific customer.

can give sample code snippets can accomplish specific search function?

thank you.

here .aspx code

  <asp:textbox id="txtsearch" runat="server" borderstyle="solid" width="218px"          ontextchanged="txtsearch_textchanged"></asp:textbox> &nbsp;<asp:button id="btnsearch" runat="server" text="search" /> </p> <div style="overflow-x:auto; width:1200px">  <asp:gridview id="gvcustomer" runat="server" autogeneratecolumns="false"          backcolor="#cccccc" bordercolor="#999999" borderstyle="solid" borderwidth="3px"          caption="customer profile" cellpadding="4" cellspacing="2" datasourceid="sqldatasourcebm"          forecolor="black" onrowcommand="gvcustomer_rowcommand"          datakeynames="applicantusername" >         <columns>             <asp:boundfield datafield="branch" headertext="branch"                  sortexpression="branch" />             <asp:boundfield datafield="applicantusername" headertext="username"                  sortexpression="applicantusername" readonly="true" />             <asp:boundfield datafield="noafirstname" headertext="first name"                  sortexpression="noafirstname" />             <asp:boundfield datafield="noalastname" headertext="last name"                  sortexpression="noalastname" />             <asp:buttonfield commandname="view profile" headertext="customer profile"                  text="view" />             <asp:buttonfield commandname="edit" headertext="customer profile" text="edit" />             <asp:buttonfield commandname="view cr" headertext="credit report" text="view" />         </columns>         <footerstyle backcolor="#cccccc" />         <headerstyle backcolor="black" font-bold="true" forecolor="white" />         <pagerstyle backcolor="#cccccc" forecolor="black" horizontalalign="left" />         <rowstyle backcolor="white" />         <selectedrowstyle backcolor="#000099" font-bold="true" forecolor="white" />         <sortedascendingcellstyle backcolor="#f1f1f1" />         <sortedascendingheaderstyle backcolor="#808080" />         <sorteddescendingcellstyle backcolor="#cac9c9" />         <sorteddescendingheaderstyle backcolor="#383838" />     </asp:gridview>     <asp:sqldatasource id="sqldatasourcebm" runat="server"          connectionstring="<%$ connectionstrings:pfciconnectionstring %>"            selectcommand="select [applicantusername], [branch], [noalastname], [noafirstname] [customerregistration] (([branch] = @branch) , ([noalastname] '%' + @noalastname + '%'))">         <selectparameters>             <asp:sessionparameter name="branch" sessionfield="applicantusername"                  type="string" />             <asp:controlparameter controlid="txtsearch" name="noalastname"                  propertyname="text" type="string" />         </selectparameters>     </asp:sqldatasource> 

since didn't provide code here , asked directions, here go. lets assume textbox name 'textbox1' , there button beside it. on click event of button should querying database customer names matches text inside 'textbox1'. query using search like:

select * customers customername "%" + textbox1.text + "%"; //assuming table name customers 

this should return customers has textbox1.text inside name. hope give insight on start from. cheers,,


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -