GridView Hyperlink field

M

Morris Neuman

Hi,

I have a GrideView which is bound to a datasourcecontrol. One of the
columns is a HyperLink to another web page passing it parameters. This
Hyperlink does not show as a hyperlink when viewing the grid. I have this
working on other pages but cannot get this to work. Don't know what I have
coded incorrectly. Please help.

Below is the definition of the GridView with the HyperLink field.


<asp:GridView ID="GridView2" runat="server" AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="Account,MessageID,SpeechFileID,VOXDIR"
DataSourceID="AccessDataSource1"
Font-Names="Verdana" Font-Size="8pt" BorderColor="#FFC080"
BorderStyle="Solid" BorderWidth="1px" Width="579px" CellPadding="5"
CellSpacing="1" ForeColor="Navy" >
<Columns>
<asp:CommandField ShowEditButton="True" EditText="Edit Status" >
<ControlStyle Font-Bold="False" ForeColor="DarkSlateGray" />
<HeaderStyle BackColor="Lavender" />
<ItemStyle BackColor="Lavender" BorderColor="SlateGray"
BorderStyle="Inset" BorderWidth="2px" />
</asp:CommandField>

<asp:HyperLinkField DataNavigateUrlFields="SpeechFileID,VOXDIR"
DataNavigateUrlFormatString="EmailMsg2.aspx?SpeechFileID{0}&VOXDIR{1}"
Text="Email Message2 via HLink" >
</asp:HyperLinkField>

</Columns>
<RowStyle BackColor="BlanchedAlmond" />
<EmptyDataTemplate>
No messages for selected mailbox
</EmptyDataTemplate>
<HeaderStyle BorderColor="#FFC080" Font-Bold="False"
BackColor="#FFC080" />
<AlternatingRowStyle BackColor="SeaShell" />
<PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" />
</asp:GridView>
 
S

Steven Cheng

Hi Morris,

As for the GridView Hyperlink column, I've performed some local test via
the page source you provided. I use a self generated DataTable as
datasource and remain the other Gridview column setting unchanged. It seems
the hyperlink can display correctly:

Here is the completely test page(aspx and codebehind), you can directly run
them in a test page on your side and compare with the problem page:

==============================
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView2" runat="server" AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False"
DataKeyNames="SpeechFileID,VOXDIR"

Font-Names="Verdana" Font-Size="8pt" BorderColor="#FFC080"
BorderStyle="Solid" BorderWidth="1px" Width="579px" CellPadding="5"
CellSpacing="1" ForeColor="Navy" >
<Columns>
<asp:CommandField ShowEditButton="True" EditText="Edit Status" >
<ControlStyle Font-Bold="False" ForeColor="DarkSlateGray" />
<HeaderStyle BackColor="Lavender" />
<ItemStyle BackColor="Lavender" BorderColor="SlateGray"
BorderStyle="Inset" BorderWidth="2px" />
</asp:CommandField>

<asp:HyperLinkField DataNavigateUrlFields="SpeechFileID,VOXDIR"
DataNavigateUrlFormatString="EmailMsg2.aspx?SpeechFileID{0}&VOXDIR{1}"
Text="Email Message2 via HLink" >
</asp:HyperLinkField>

</Columns>
<RowStyle BackColor="BlanchedAlmond" />
<EmptyDataTemplate>
No messages for selected mailbox
</EmptyDataTemplate>
<HeaderStyle BorderColor="#FFC080" Font-Bold="False"
BackColor="#FFC080" />
<AlternatingRowStyle BackColor="SeaShell" />
<PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" />
</asp:GridView>

</div>
</form>
</body>
=============================

===============code behind============
public partial class DataTestPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind_Test_Data();
}
}

void Bind_Test_Data()
{
DataTable dt = new DataTable("TestTable");

dt.Columns.Add("SpeechFileID");
dt.Columns.Add("VOXDIR");

for (int i = 0; i < 10; ++i)
{
dt.Rows.Add("SpeechFile_" + i, "VOXDIR_" + i);
}

GridView2.DataSource = dt;
GridView2.DataBind();
}
}
=============================

If there is anything unclear or any further finding, please feel free to
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.




--------------------
 
M

Morris Neuman

Cannot get my code to work. I have a similar grid on another page with
hyperlink data navigation URL and that work.

Anyway, I created a column with a template field and then placed the
hyperlink in the template and that seems to work.

Thanks for your help.
 
S

Steven Cheng

Hi Morris,

Thanks for your reply. If you need any help later, please feel free to post
here.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

--------------------
From: =?Utf-8?B?TW9ycmlzIE5ldW1hbg==?= <[email protected]>
References: <[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top