I am highlighting a certain LinkButton within my DataList when the linkbutton is pressed. Each row has a link button, and when the user presses the next link button from any of the rows, the previous highlighted link button should get the normal transparent background.
For highlighting, I am using the following:
protected void DataList_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "select")
{
LinkButton highlighted = ((LinkButton)(e.Item.FindControl("Item")));
highlighted.BackColor = System.Drawing.Color.Yellow;
...
}
How do I ‘un-highlight’ the previous link button, when the user choose any other link button from the data list?
Since the post back are taking place, I can’t have a global LinkButton variable to check the next time to store the previously clicked LinkedButton.
Any suggestions?
If you are rebinding the grid on page load, the color of the LinkButtons should be reset. However, something like this should be able to set the background color of all linkbuttons to transparent:
VB.NET:
C#: