<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Go" onclick="Button1_Click" />
<table><tr><td><p><asp:Label ID="Label2" runat="server" Text="label"></asp:Label> </p></td></tr></table>
<asp:GridView ID="GridView1" runat="server" >
Now switch to design mode and use the following code.
To bind the grid, create the following method:
Then double-click on the "Go" button and use the following code:
Now run the application, it will look as in the following:
Now enter some characters in the TextBox that do not match the specified table's records (that we inserted into the table); that will produce the following message:
Now do not enter a value into the TextBox and click on the "Go" button, that will display all the records as in the following:
Now enter the specific name and click on the "Go" button to search the records specific to name as follows:
In the all preceding examples, we learned how to search the records.
- For detailed code please download the zip file attached above.
- Don't forget to apply the relevant changes in the Web.config file depending on your Server location.
Now we have learned how to search the records from a database and display them in the GridView. I hope this article is useful for all students and beginners. If you have any suggestion related to this article please contact me.