<asp:TemplateField HeaderText="link" ItemStyle-HorizontalAlign="Center">
<asp:HyperLink ID="link" runat="server" NavigateUrl='<%# Eval("link").ToString() %>'
ImageUrl='<%#(String.IsNullOrEmpty(Eval("link").ToString()) ? "/Images/cross-button.png" : "/Images/download.gif")%>'
ToolTip='<%#(String.IsNullOrEmpty(Eval("link").ToString()) ? "empty link" : "go to link")%>'
Target="_blank" BorderStyle="None" ForeColor="Transparent">
In the code-behind I only use databind, and then export to pdf.
Everything works perfectly except this one column that is empty.
I have tried to replace:
[code]
cellText = Server.HtmlDecode(gvProducts.Rows[rowIndex].Cells[j].Text);[/code]
with
[code]
cellText = Server.HtmlDecode((gvProducts.Rows[rowIndex].Cells[j].FindControl("link") as HyperLink).NavigateUrl);[/code]
But in output pdf in all columns I have the value of HyperLink.
Can you please help me figure out the problem?
Thanks in advance.
My code below.
[code]
//export rows from GridView to table
for (int rowIndex = 0; rowIndex < gvProducts.Rows.Count; rowIndex++)
{
if (gvProducts.Rows[rowIndex].RowType == DataControlRowType.DataRow)
{
for (int j = 0; j < gvProducts.Columns.Count - 1; j++)
{
//fetch the column value of the current row
//cellText = Server.HtmlDecode(gvProducts.Rows[rowIndex].Cells[j].Text);
cellText = Server.HtmlDecode((gvProducts.Rows[rowIndex].Cells[j].FindControl("link") as HyperLink).NavigateUrl);
//create a new cell with column value
//cell = new PdfPCell(new Phrase(cellText));
cell = new PdfPCell(new Phrase(cellText, FontFactory.GetFont("nina fett", 8)));
//Set Color of Alternating row
if (rowIndex % 2 != 0)
{
cell.BackgroundColor = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#9ab2ca"));
}
else
{
cell.BackgroundColor = new BaseColor(System.Drawing.ColorTranslator.FromHtml("#f1f5f6"));
}
//add the cell to the table
table.AddCell(cell);
}
}
}[/code]