hi... to all
i have created a webform in that form one gridview and above that one textbox is there.
i have connected to my database programatically..
now my question is when i type a text in the textbox and press enter button,
it should search in gridview only.. and again the data which searched had to display in sme gridview
Loading

Amit ChoudharyRank #145 · 15.8K reputationPosted Feb 16, 2011, 2:09 AM EST
Hope you got my point.
shashi reddy139 reputationPosted Feb 16, 2011, 2:16 AM EST
give me .any example plz
Amit ChoudharyRank #145 · 15.8K reputationPosted Feb 16, 2011, 8:00 PM EST
I found the easiest way of doing this:
for (int j = 0; j < GridView1.Rows.Count; j++)
{
for (int i = 0; i < GridView1.Columns.Count; i++)
{
if ( GridView1.Rows[j].Cells[i].Text.Contains("search criteria"))
{
GridView1.Rows[j].Cells[i].Visible = true;
break;
}
else
{
GridView1.Rows[j].Cells[i].Visible = false;
}
}
}
This will search the Grid in very efficient way..I'll post another solution that i have mentioned to you soon..
Amit ChoudharyRank #145 · 15.8K reputationPosted Feb 16, 2011, 8:15 PM EST
Write this code in the searchbutton click event.
IEnumerable
where e["Description"].ToString().Contains(srchTxt.Text)
select e;
lblMessage.Text = "Search result found: " + result.Count();
DataTable dtSearched = dt.Clone();
foreach(DataRow drow in result)
{
dtSearched.ImportRow(drow);
}
Bind the Grid to dtSerached datatable to show the results.
Thanks.
Suthish NairRank #92 · 22.8K reputationPosted Feb 17, 2011, 9:12 AM EST