特定のグリッド ビュー行をクリックしたときに、グリッド ビュー行に背景色を適用しようとしていました。
<script type="text/javascript">
function ChangeRowColor(objref) {
objref.style.backgroundcolor = "red";
}
</script>
<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
runat="server" AutoGenerateColumns="false" OnRowCreated="GridView1_RowCreated">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
<asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="150" />
</Columns>
</asp:GridView>
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
string rowID = String.Empty;
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "ChangeRowColor(this)");
}
}
しかし、その行をクリックしても何も起こらなかった..助けてください..