i created a page for searching records from database it is working well for repeater control but i want to display result in gridview......plz help
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate><table width="100%"><tr><th>NAME</th><th>LAST_NAME</th><th>EMAIL</th></tr></HeaderTemplate>
<ItemTemplate>
<tr><td><%#DataBinder.Eval(Container.DataItem, "fname")%></a></td>
<td><%#DataBinder.Eval(Container.DataItem, "lname")%></td>
<td><%#DataBinder.Eval(Container.DataItem, "email")%></td></tr>
</ItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:Repeater>
stored procedure:
CREATE PROCEDURE spSearchByString @Search_String varchar(50) AS SELECT [db_main].fname, [db_main].lname, [db_main].email
FROM [db_main]
WHERE ([db_main].fname LIKE '%' + @Search_String + '%' OR
[db_main].lname LIKE '%' + @Search_String + '%')
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["searchString"] != null)
{
DisplaySearchResults(Request.QueryString["searchString"]);
}
}
public void DisplaySearchResults(string strSearch)
{
string conString = ConfigurationManager.ConnectionStrings["abcConnectionString"].ConnectionString;
SqlCommand cmd = new SqlCommand("spSearchByString", new SqlConnection(conString));
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Search_String", strSearch);
cmd.Connection.Open();
Repeater1.DataSource = cmd.ExecuteReader();
Repeater1.DataBind();
cmd.Connection.Close();
cmd.Connection.Dispose();
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Default3.aspx?searchString=" + Server.UrlEncode(TextBox1.Text));
}
}
stored pr