Hello ,
if you have the grid view .
<asp:GridView ID="gvEmployees" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" DataSourceID="objGroups" OnRowCommand="gdvGroups_RowCommand" Width="60%" meta:resourcekey="gdvGroupsResource1">
<FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#E3EAEB" />
<Columns>
<asp:BoundField HeaderText="Employee ID" />
<asp:BoundField HeaderText="Employee Name" />
</Columns>
<PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#7C6F57" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
You write this code in ddl selected index changed function.
protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
gvEmployees.DataBind();
foreach (GridViewRow row in gvEmployees.Rows)
{
if (row.Cells[1].Text == ddl.SelectedItem.Text)
{
row.BackColor = System.Drawing.Color.Blue;
}
}
}
That's it!
Regards
Abraheem Abulubbad
.NET Developer