<asp:gridview pagerstyle-cssclass="dataGridPager" onpageindexchanging="pageIndexChange" onselectedindexchanged="selectedRowChanged" runat="server" onrowdatabound="machineGridView" xmlns:asp="#unknown">
PageSize="25" UseAccessibleHeader="true" AllowPaging="true" SelectedRowStyle-BackColor="Blue"
ID="dataGrid" CssClass="dataGrid" >
<alternatingrowstyle backcolor="WhiteSmoke" horizontalalign="Center" />
<headerstyle font-bold="true" horizontalalign="Center" backcolor="#2C4E5B" forecolor="White" />
<pagersettings visible="true" mode="Numeric" />
<pagerstyle horizontalalign="Center" font-underline="true" />
<selectedrowstyle font-bold="true" />
</asp:gridview>
For example you have dataGrid like above
Try this in your .cs file
protected void machineGridView(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onmouseover"] = "this.style.color='red';";
e.Row.Attributes["onmouseout"] = "this.style.color='black';";
e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.dataGrid, "Select$" + e.Row.RowIndex);
}
}
protected void selectedRowChanged(object sender, EventArgs e)
{
String test = dataGrid.SelectedRow.Cells[0].Text;
}