GridView Hyperlink field

Discussion in 'ASP .Net Web Controls' started by Morris Neuman, Jan 18, 2009.

  1. 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>

    --
    Thanks
    Morris
     
    Morris Neuman, Jan 18, 2009
    #1
    1. Advertising

  2. Morris Neuman

    Steven Cheng Guest

    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:
    .

    ==================================================
    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.




    --------------------
    >From: =?Utf-8?B?TW9ycmlzIE5ldW1hbg==?= <>
    >Subject: GridView Hyperlink field
    >Date: Sun, 18 Jan 2009 15:03:16 -0800


    >
    >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"
    >
     
    Steven Cheng, Jan 19, 2009
    #2
    1. Advertising

  3. 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.
    --
    Thanks
    Morris


    ""Steven Cheng"" wrote:

    > 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:
    > .
    >
    > ==================================================
    > 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.
    >
    >
    >
    >
    > --------------------
    > >From: =?Utf-8?B?TW9ycmlzIE5ldW1hbg==?= <>
    > >Subject: GridView Hyperlink field
    > >Date: Sun, 18 Jan 2009 15:03:16 -0800

    >
    > >
    > >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"
    > >

    >
    >
     
    Morris Neuman, Jan 19, 2009
    #3
  4. Morris Neuman

    Steven Cheng Guest

    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:
    .

    --------------------
    >From: =?Utf-8?B?TW9ycmlzIE5ldW1hbg==?= <>
    >References: <>

    <>
    >Subject: RE: GridView Hyperlink field
    >Date: Mon, 19 Jan 2009 12:11:02 -0800


    >
    >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.
    >--
    >Thanks
    >Morris
    >
    >
    >""Steven Cheng"" wrote:
    >
    >> 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
    >> t
     
    Steven Cheng, Jan 20, 2009
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carlos
    Replies:
    1
    Views:
    8,909
    PeterKellner
    Jun 8, 2006
  2. barkster

    GridView Hyperlink Field Append URL?

    barkster, Oct 11, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    1,099
    Siva M
    Oct 12, 2006
  3. =?Utf-8?B?UnV5IENhc3RlbGxp?=

    Retrieve information from Hyperlink and Button field on a GridView

    =?Utf-8?B?UnV5IENhc3RlbGxp?=, Oct 18, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    507
    =?Utf-8?B?UnV5IENhc3RlbGxp?=
    Oct 18, 2006
  4. Bogdan
    Replies:
    2
    Views:
    1,836
    Alexey Smirnov
    Jul 20, 2009
  5. Dmitry N.Ananyev

    May I disable underline in one gridview Hyperlink field ?

    Dmitry N.Ananyev, Jun 29, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    280
    Jagdish
    Jul 1, 2005
Loading...

Share This Page