Here I have created sample that will help you out.
HTML
<div>
<style type="text/css">
.Lime
{
background-color: Lime;
}
</style>
Number :
<asp:TextBox ID="txtNumber" runat="server" AutoPostBack="true" OnTextChanged="TextChanged" />
<br />
<br />
<asp:GridView ID="GridView1" CssClass="Grid" runat="server" OnRowDeleting="OnRowDeleting"
AutoGenerateColumns="false" OnRowDataBound="OnRowDataBound">
<Columns>
<asp:BoundField DataField="Item" HeaderText="Item" />
<asp:BoundField DataField="Price" HeaderText="Price" />
<asp:CommandField ShowDeleteButton="True" ButtonType="Button" />
</Columns>
</asp:GridView>
</div>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[2] { new DataColumn("Item"), new DataColumn("Price") });
dt.Rows.Add("Shirt", 450);
dt.Rows.Add("Jeans", 3200);
dt.Rows.Add("Trousers", 1900);
dt.Rows.Add("Tie", 185);
dt.Rows.Add("Cap", 100);
ViewState["dt"] = dt;
BindGrid();
}
}
protected void BindGrid()
{
GridView1.DataSource = ViewState["dt"] as DataTable;
GridView1.DataBind();
}
protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
{
int index = Convert.ToInt32(e.RowIndex);
DataTable dt = ViewState["dt"] as DataTable;
dt.Rows[index].Delete();
ViewState["dt"] = dt;
BindGrid();
}
protected void TextChanged(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
SetLime(row);
}
}
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string item = e.Row.Cells[0].Text;
foreach (Button button in e.Row.Cells[2].Controls.OfType<Button>())
{
if (button.CommandName == "Delete")
{
button.Attributes["onclick"] = "if(!confirm('Do you want to delete " + item + "?')){ return false; };";
}
}
SetLime(e.Row);
}
}
private void SetLime(GridViewRow row)
{
if (row.RowType == DataControlRowType.DataRow)
{
if (!string.IsNullOrEmpty(txtNumber.Text))
{
if (row.RowIndex >= Convert.ToInt32(txtNumber.Text))
{
row.CssClass = "Lime";
}
else
{
row.CssClass = "";
}
}
}
}
Screenshot
