I am trying to add linkbutton with URL to gridview subtotal row. I'm using the below code and not able to add URL.
Can anyone please provide suggestions on how this can be handled?
Update 1:
private void AddTotalRow(string labelText, string value)
{
GridViewRow row = new GridViewRow(0, 0, DataControlRowType.DataRow, DataControlRowState.Normal);
row.BackColor = ColorTranslator.FromHtml("#F9F9F9");
row.Cells.AddRange(new TableCell[3] { new TableCell{ Text = labelText, HorizontalAlign = HorizontalAlign.Right },
new TableCell{ Text = value, HorizontalAlign = HorizontalAlign.Right },
HyperLinkCell(value, "http://www.google.com") });
}
protected TableCell HyperLinkCell(string text, string url)
{
TableCell cell = new TableCell();
HyperLink link = new HyperLink();
try
{
link.Text = text;
link.Font.Underline = true;
link.Target = "_blank";
link.NavigateUrl = url;
link.Attributes.Add("style", "color:Black;");
cell.Controls.Add(link);
}
catch (Exception ex)
{
throw ex;
}
return cell;
}