Hi all,
I have created an web application in ASP.NET 2.0 (using C#). The functionality I am implementing is search engine of site. I am not using any utility for that. I have used a code from internet.
Now my search text box and button is in master page and my data grid is in content page . So when user will click on search button, I can fill data grid.
For this I will write my code on master page code behind and then I will access datagrid from master page. But after this I have 1 problem and it is how and where I will have to handle paging code for datagrid ?
Can any one please help me in this ?
Thanks and Regards
Prasad . G . Godbole
Loading
Prasad GodbolePosted Nov 21, 2009, 6:08 AM
Thanks... yups... I implemented it in content page instead of master page and its working perfectly
Thanks and Regards
Prasad . G . Godbole
Purushottam RathorePosted Nov 18, 2009, 6:45 AM
Don't write the code on master page. Create new page as SearchResult.aspx
Write the code on button click for search:
protected void Button1_Click(object sender, EventArgs e)
{
string searchText = TextBoxSearch.Text;
Response.Redirect("SearchResult.aspx?Search=" + searchText);
}
SearchResult.aspx:
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["Search"].ToString() != null && Request.QueryString["Search"].ToString() != "")
{
ViewState["Search"] = Request.QueryString["Search"].ToString();
BindSearchResult();
}
}
private void BindSearchResult()
{
if (ViewState["Search"].ToString() != "")
{
// Get the record from the database and bind DataGrid/GridView.
//
}
}
Kirtan PatelPosted Nov 7, 2009, 9:46 AM
Dont Implement Search Logic on master page ..
just Put Search Text Box and Search Button on Master page .and In Button Code Write Code For Passing Search QueryString to Separate SearchPage like
in Search Button Code
Now in Search.aspx there will be a GridView
in load Event of Search.aspx there will be code to retrieve that Query String passed from SerachButton ..
retrieve that Search String and Fetch The Data From Database According to that String and Show in SearchPage gridView
if my Answer Helped you then Please mark "Do you like this answer " please :)