p_love
asked on
Gridview nor rendering hyperlinks, just displaying HTML tags
Hello,
I have a GridView and I am processing the values in the first column: This creates a hyperlink to a new page and passes the value of the link in. This works fine working locally, but when I upload to my webserver, the first column is rendering as the HTML:
Code
e.Row.Cells(0).Attributes. Add("oncli ck", "javascript:void(window.op en('Drilld owns/Popup _Window_Mi lestones_G antt.aspx? PROJECT_ID =" & DataBinder.Eval(e.Row.Data Item, "PROJECT_ID") & "&PROJECT=" & Server.HtmlEncode(DataBind er.Eval(e. Row.DataIt em, "PROJECT")) & "','win',centerTopLeftPos( 870,610))) ;")
Rendering on remote server as:
<span style='text-decoration:und erline;cur sor:pointe r;'>AZD590 4 MPO MS</span>
i.e. I am actually seeing <span.... in the gridview. Funnily enough the hyperlink still works.
Grid view declared:
<asp:GridView ID="grdLevel1MilestonesOve rview" runat="server" AllowPaging="true" PageSize="16" Width="950" AutoGenerateColumns="false " Font-Size="6pt" BackColor="#eeeeee">
<HeaderStyle CssClass="header" />
<PagerStyle CssClass="footer" />
<RowStyle CssClass="row" />
<AlternatingRowStyle CssClass="alternating" />
<Columns>
<asp:BoundField DataFormatString="<span style='text-decoration:und erline;cur sor:pointe r;'>{0}</s pan>" DataField="PROJECT" HeaderText="PROJECT" ItemStyle-Wrap="true" >
<ItemStyle Width="180px"/>
</asp:BoundField>
<asp:BoundField DataField="MS5" HeaderText="MS5"/>
<asp:BoundField DataField="FGLPD" HeaderText="FGLPD"/>
<asp:BoundField DataField="TG2" HeaderText="TG2"/>
<asp:BoundField DataField="FTIM" HeaderText="FTIM"/>
<asp:BoundField DataField="POP" HeaderText="POP"/>
<asp:BoundField DataField="FTIP" HeaderText="FTIP"/>
<asp:BoundField DataField="TG2.5" HeaderText="TG2.5"/>
<asp:BoundField DataField="FDIDF" HeaderText="FDIDF"/>
<asp:BoundField DataField="POC" HeaderText="POC"/>
<asp:BoundField DataField="TG3" HeaderText="TG3"/>
<asp:BoundField DataField="TG4" HeaderText="TG4"/>
<asp:BoundField DataField="MS8" HeaderText="MS8"/>
<asp:BoundField DataField="MS9" HeaderText="MS9"/>
</Columns>
</asp:GridView>
I have a GridView and I am processing the values in the first column: This creates a hyperlink to a new page and passes the value of the link in. This works fine working locally, but when I upload to my webserver, the first column is rendering as the HTML:
Code
e.Row.Cells(0).Attributes.
Rendering on remote server as:
<span style='text-decoration:und
i.e. I am actually seeing <span.... in the gridview. Funnily enough the hyperlink still works.
Grid view declared:
<asp:GridView ID="grdLevel1MilestonesOve
<HeaderStyle CssClass="header" />
<PagerStyle CssClass="footer" />
<RowStyle CssClass="row" />
<AlternatingRowStyle CssClass="alternating" />
<Columns>
<asp:BoundField DataFormatString="<span style='text-decoration:und
<ItemStyle Width="180px"/>
</asp:BoundField>
<asp:BoundField DataField="MS5" HeaderText="MS5"/>
<asp:BoundField DataField="FGLPD" HeaderText="FGLPD"/>
<asp:BoundField DataField="TG2" HeaderText="TG2"/>
<asp:BoundField DataField="FTIM" HeaderText="FTIM"/>
<asp:BoundField DataField="POP" HeaderText="POP"/>
<asp:BoundField DataField="FTIP" HeaderText="FTIP"/>
<asp:BoundField DataField="TG2.5" HeaderText="TG2.5"/>
<asp:BoundField DataField="FDIDF" HeaderText="FDIDF"/>
<asp:BoundField DataField="POC" HeaderText="POC"/>
<asp:BoundField DataField="TG3" HeaderText="TG3"/>
<asp:BoundField DataField="TG4" HeaderText="TG4"/>
<asp:BoundField DataField="MS8" HeaderText="MS8"/>
<asp:BoundField DataField="MS9" HeaderText="MS9"/>
</Columns>
</asp:GridView>
Protected Sub grdLevel1MilestonesOverview_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdLevel1MilestonesOverview.RowDataBound
' We need to catch these events as the data is bound to the grid view so we can
' control for formatting of the dates, and so we can create hyperlinks from
' the project name to the study level gantt chart
If e.Row.RowType = DataControlRowType.DataRow Then
If IsDate(e.Row.Cells(1).Text.Trim) = True Then
e.Row.Cells(1).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(1).Text))
End If
If IsDate(e.Row.Cells(2).Text.Trim) = True Then
e.Row.Cells(2).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(2).Text))
End If
If IsDate(e.Row.Cells(3).Text.Trim) = True Then
e.Row.Cells(3).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(3).Text))
End If
If IsDate(e.Row.Cells(4).Text.Trim) = True Then
e.Row.Cells(4).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(4).Text))
End If
If IsDate(e.Row.Cells(5).Text.Trim) = True Then
e.Row.Cells(5).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(5).Text))
End If
If IsDate(e.Row.Cells(6).Text.Trim) = True Then
e.Row.Cells(6).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(6).Text))
End If
If IsDate(e.Row.Cells(7).Text.Trim) = True Then
e.Row.Cells(7).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(7).Text))
End If
If IsDate(e.Row.Cells(8).Text.Trim) = True Then
e.Row.Cells(8).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(8).Text))
End If
If IsDate(e.Row.Cells(9).Text.Trim) = True Then
e.Row.Cells(9).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(9).Text))
End If
If IsDate(e.Row.Cells(10).Text.Trim) = True Then
e.Row.Cells(10).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(10).Text))
End If
If IsDate(e.Row.Cells(11).Text.Trim) = True Then
e.Row.Cells(11).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(11).Text))
End If
If IsDate(e.Row.Cells(12).Text.Trim) = True Then
e.Row.Cells(12).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(12).Text))
End If
If IsDate(e.Row.Cells(13).Text.Trim) = True Then
e.Row.Cells(13).Text = String.Format("{0:dd-MM-yy}", CDate(e.Row.Cells(13).Text))
End If
' Add the drill down capability to the first column (project) to allow us to pass the project name
' into a separate web page to study the level 1/ level 2 combined gantt chart
e.Row.Cells(0).Attributes.Add("onclick", "javascript:void(window.open('Drilldowns/Popup_Window_Milestones_Gantt.aspx?PROJECT_ID=" & DataBinder.Eval(e.Row.DataItem, "PROJECT_ID") & "&PROJECT=" & Server.HtmlEncode(DataBinder.Eval(e.Row.DataItem, "PROJECT")) & "','win',centerTopLeftPos(870,610)));")
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Perhaps some sort of default setting on the local machine, or an XP vs. Server thing... I run into that particularly when trying to determine the logged on user.
ASKER