G
Guest
Hi,
So I am trying to have a <asp:ButtonField> in the columns part of my
gridview, redirect the user to another page with the index/DataValue of the
Row that they pushed the button in. It would be nice if there was a combined
thing with <asp:ButtonField and <asp:HyperLinkField. Since there is not, how
would I accomplish my objective. By clicking a button with my own specified
image that redirects the user to another page. I tried:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "EditItem")
{
try
{
int index = Convert.ToInt32(e.CommandArgument);
GridView1.SelectedIndex = index;
int id = Convert.ToInt32(GridView1.SelectedValue);
Response.Redirect(string.Format("EditSku.aspx?id={0}", id));
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
But the Response.Redirect is throwing an exception.
Thanks,
Matt
So I am trying to have a <asp:ButtonField> in the columns part of my
gridview, redirect the user to another page with the index/DataValue of the
Row that they pushed the button in. It would be nice if there was a combined
thing with <asp:ButtonField and <asp:HyperLinkField. Since there is not, how
would I accomplish my objective. By clicking a button with my own specified
image that redirects the user to another page. I tried:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "EditItem")
{
try
{
int index = Convert.ToInt32(e.CommandArgument);
GridView1.SelectedIndex = index;
int id = Convert.ToInt32(GridView1.SelectedValue);
Response.Redirect(string.Format("EditSku.aspx?id={0}", id));
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
But the Response.Redirect is throwing an exception.
Thanks,
Matt