I have a GridView which has ID, Name and Type.
Code behind:
protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes["onclick"] = ClientScript.GetPostBackClientHyperlink(this.gridView, "Select$" + e.Row.RowIndex);
}
}
public void gridView_Command(object sender, GridViewCommandEventArgs e)
{
// some code here //
}
The GridView:
<asp:GridView ID="gridView" runat="server" OnRowCommand="gridView_Command" />
<columns>
<asp:BoundField DataField="ID" />
<asp:HyperLinkField DataTextField="Name" />
<asp:BoundField DataField="Type" />
</columns>
The Name is click enabled because of the HyperlinkField. The problem here is I don't want the gridview_Command to be triggered if the row is clicked. I just want the Name field. For example, if the column of the Type is clicked, don't fire the gridView_Command.
gridView_RowDataBound. Sorry for the confusion.OnRowDataBoundtoOnRowCommand?