Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ai hav 1task can u help me question: any 1 send me sample coding for search and display next page search output in gridview
Posted

1 solution

Create a table with following columns

Id(int,primary and Identity)
Name(varchar(50))
Address (varchar(50)
Email (varchar(50)


Insert some values to this table

and create a asp.net like follows

ASP.NET
 <form id="form1" runat="server">

    <div>  

   <table>

    <tr>

    <td> 

       Search

        </td>

        <td>

        <asp:textbox id="TextBox1" runat="server" xmlns:asp="#unknown"></asp:textbox>

        </td>

        <td> 

        <asp:button id="Button1" runat="server" text="Go" onclick="Button1_Click" xmlns:asp="#unknown" />

        </td>

        

        </tr>
 

</table>

<table><tr><td><p><asp:label id="Label2" runat="server" text="label" xmlns:asp="#unknown"></asp:label>  </p></td></tr></table>

 

<asp:gridview id="GridView1" runat="server" xmlns:asp="#unknown">

    </asp:gridview> 

    </div>

 </form>


To Bind the grid write following method
C#
private void BindGrid()
{
string con=ConfigurationManager.
    ConnectionStrings["connectionStringName"].ConnectionString;
string query="select *from emp where Name like'"+TextBox1.Text+"%'";
SqlDataAdapter da= new SqlDataAdapter(query,con);
DataSet ds=new DataSet();
da.Fill(ds);
GridView1.Datasorce=ds;
GridView1.DataBind();
}


Then double-click on the "Go" button and use the following code:

C#
if(dr.HasRows)
{
dr.read();
BindGrid();
GridView1.Visible=true;
TextBox1.Text="";
Label1.Text="";
}
else
{
GridView1.Visible=false;
Label1.Visible=true;
Label1.Text="The Search Term"+TextBox1.Text+  Is Not Available in The Records";
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900