i have four button in my templatefield of gridview. i need to change the css of clicked button in every row separately. for example in row one, first button is clicked. then it have to be yellow. and in row 3, second button is clicked. then it have to be yellow and so on. here is my gridview
<asp:GridView OnRowCommand="SelectedPollGridView_RowCommand" ID="SelectedPollGridView" runat="server" AutoGenerateColumns="False" DataKeyNames="PollID" DataSourceID="SelectedPollSqlDataSource">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label Visible="false" ID="PollIDLabel" runat="server" Text='<%#Eval("PollID") %>'></asp:Label>
<div runat="server" id="MainDiv" class="text-right">
<div runat="server" id="O1Div" visible='<%#Eval("O1Vis") %>' class="radio ">
<asp:Button CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' CommandName="O1" ID="O1Button" runat="server" Text=" 1" />
</div>
<div runat="server" id="O2Div" visible='<%#Eval("O2Vis") %>' class="radio">
<asp:Button CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' CommandName="O2" ID="O2Button" runat="server" Text=" 2" />
</div>
<div runat="server" id="O3Div" visible='<%#Eval("O3Vis") %>' class="radio">
<asp:Button CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' CommandName="O3" ID="O3Button" runat="server" Text=" 3" />
</div>
<div runat="server" id="O4Div" visible='<%#Eval("O4Vis") %>' class="radio">
<asp:Button CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' CommandName="O4" ID="O4Button" runat="server" Text=" 4" />
</div>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
here is code behind:
protected void SelectedPollGridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = SelectedPollGridView.Rows[index];
Label myPollIDLAbel = (Label)row.FindControl("PollIDLabel");
if (e.CommandName == "O1")
{
//chnaging the css of O1 button JUST IN THIS ROW
}
else if (e.CommandName == "O2")
{
//chnaging the css of O2 button JUST IN THIS ROW
}
else if (e.CommandName == "O3")
{
//chnaging the css of O3 button JUST IN THIS ROW
}
else if (e.CommandName == "O4")
{
//chnaging the css of O4 button JUST IN THIS ROW
}
}