This is a migrated thread and some comments may be shown as answers.

search in Grid

1 Answer 35 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dawson
Top achievements
Rank 1
Dawson asked on 27 Nov 2013, 12:30 PM
Hi
I hav a textbox and a search button. I enter a text to search for a value in the Grid. I want some sort of identification that the search is successful like highlight the selected search text in the grid.please help on this.

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 27 Nov 2013, 12:42 PM
Hi Dawson,

Please try the following code snippet to have a cell highlighted on search.

ASPX:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<telerik:RadGrid ID="RadGrid1" runat="server">
    <MasterTableView >
        . . .
    </MasterTableView>   
</telerik:RadGrid>

C#:
protected void Button1_Click(object sender, EventArgs e)
{
   string text = TextBox1.Text;
   foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
   {
       foreach (GridColumn col in RadGrid1.MasterTableView.Columns)
       {
           if (text == item[col.UniqueName].Text)
           {
               TableCell cell = item[col.UniqueName];
               cell.BackColor = Color.Red;
           }               
       }
   }
}

Thanks,
Princy
Tags
Grid
Asked by
Dawson
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or