Hello,
I have an asp.net webform application that has a link button inside a listview.
What I want to do is to highlight/change color of the selected button on Itemcommand.
I have tried a lot of solutions with no luck. It changes the color but it doesn't change back when i click another button.
Any help will be so much appreciated.
Thanks
Samira
What I have tried:
I tried to change color of the selected/clicked button on ItemCommand , ItemDataBound and button click.
Link button inside listview:
<asp:ListView runat="server" ID="subs_view" DataSourceID="SubsFilterSqlDataSource" OnItemCommand="subs_view_ItemCommand" OnItemDataBound= "subs_view_ItemDataBound">
<ItemTemplate>
<asp:LinkButton cssClass="col-md-9 link-btn" runat="server" ID="btnSubs" CommandName="subs" CommandArgument='<%#Eval("code") %>' Text='<%#Eval("SubCat_CountItems") %>' OnClick="btnSubs_Click"> </asp:LinkButton>
</ItemTemplate>
</asp:ListView>
I tried to change colors in different ways:
protected void subs_view_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "subs")
{
LinkButton linkbtn = (LinkButton)e.Item.FindControl("btnSubs");
linkbtn.ForeColor = System.Drawing.Color.Red;
}
}
protected void btnSubs_Click(object sender, EventArgs e)
{
}
--
protected void subs_view_ItemDataBound(object sender, ListViewItemEventArgs e)
{
}