I have an asp page with a gridview on. I have also added a clientscript to each bound row to highlight/un-higlight on mouse over/out. I have added an asp:button as a templatefield and bound a value to the CommandArgument. In IE and FIrefox I get the expected behaviour where the CommandName is passed to the _RowCommand event. However, when in Safari I only ever see the CommanName of "Select" passed to RowCommand.
The expected behaviour is that when a bound row is clicked the "Select" paramater is passed to the RowCommand event. When the Button in the row is clicked the argument "Remove" is passed.
protected void gvContacts_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onMouseOver", "Highlight(this)");
e.Row.Attributes.Add("onMouseOut", "UnHighlight(this)");
e.Row.Attributes["onclick"] = Page.ClientScript.GetPostBackClientHyperlink(gvContacts, "Select$" + e.Row.RowIndex);
e.Row.Attributes["style"] = "cursor:pointer";
}
}
protected void gvContacts_RowCommand(object sender, GridViewCommandEventArgs e)
{
switch (e.CommandName) //Always "Select" when browser is Safari.
{
case "Select":
Session["clientID"] = gvContacts.Rows[Convert.ToInt32(e.CommandArgument)].Cells[0].Text;
Response.Redirect("../Contacts/ContactEdit.aspx?readin=1");
break;
case "Remove":
//Remove the client from the list
Company company = new Company();
company.Get(Int32.Parse(Session["CompanyID"].ToString()), ((Model)Session["model"]).ConnectionString);
company.RemoveUser(Int32.Parse(e.CommandArgument.ToString()));
BindGrid(company.ID);
break;
}
}
HTML for itemtemplate
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnRemove" runat="server" Text="Remove" CommandName="Remove" OnClientClick="return confirmRemove();"
CommandArgument='<%# Eval("ID") %>' />
</ItemTemplate>
Any thoughts would be appreciated. Thanks