Make hyperlink appear in a datagrid cell

Discussion in 'ASP .Net Datagrid Control' started by Lynn, Apr 21, 2004.

  1. Lynn

    Lynn Guest

    Hi

    I have a datagrid, on a form, which contains a custom column style that converts a data grid text field into a linklabel. The problem I am having is that the link doesn't appear until the cell is clicked. Is there a way to have the link appear when the datagrid is loaded

    Thanks
    Lynn
    Lynn, Apr 21, 2004
    #1
    1. Advertising

  2. Hi Lynn,

    Based on my understanding, you want to add a column with is hyperlink class
    in your datagrid control.

    Asp.net DataGrid control has a build-in HyperLinkColumn, you can just
    leverage it to display a column of hyperlinks in datagrid, Like this:

    private void Page_Load(object sender, System.EventArgs e)
    {
    if(!this.IsPostBack)
    {
    DataSet ds=new DataSet ();
    SqlDataAdapter adapter=new SqlDataAdapter("select * from
    jobs","server=localhost;database=pubs;uid=sa;pwd=");
    adapter.Fill(ds);
    DataGrid1.DataSource=ds;
    DataGrid1.DataBind();
    }
    }

    //Html View Code
    <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
    absolute; TOP: 64px" runat="server"
    Width="400px" Height="232px">
    <Columns>
    <asp:HyperLinkColumn DataTextField="job_desc"
    HeaderText="HyperLinkColumn"
    NavigateUrl="http://msdn.microsoft.com"></asp:HyperLinkColumn>
    </Columns>
    </asp:DataGrid>

    It should work as you expected.

    Surely, you can just TemplateColumn to add HyperLink control in that
    column, this will give more control on the behavior, like this:
    <asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 96px; POSITION:
    absolute; TOP: 64px" runat="server"
    Width="400px" Height="232px">
    <Columns>
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:HyperLink ID="hl" Runat="server"
    Text='<%#DataBinder.Eval(Container.DataItem, "job_desc")%>'
    NavigateUrl="http://msdn.microsoft.com"></asp:HyperLink>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:DataGrid>

    ================================================
    Please apply my suggestion above and let me know if it helps resolve your
    problem.

    Thank you for your patience and cooperation. If you have any questions or
    concerns, please feel free to post it in the group. I am standing by to be
    of assistance.

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jeffrey Tan[MSFT], Apr 22, 2004
    #2
    1. Advertising

  3. Hi Lynn,

    Does my reply make sense to you? Do you still have any concern on this
    issue?

    Please feel free to post. Thanks

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jeffrey Tan[MSFT], Apr 26, 2004
    #3
  4. Lynn

    lynn Guest

    Jeffrey

    I had attempted two replies to you last week. But for some reason, the replies are not being posted. Any how, here is my question again. How do I apply your response to a datagrid that is placed on a Windows form instead of an Asp.Net datagrid control

    Thanks
    Lyn

    ----- "Jeffrey Tan[MSFT]" wrote: ----

    Hi Lynn

    Does my reply make sense to you? Do you still have any concern on this
    issue

    Please feel free to post. Thank

    Best regards
    Jeffrey Ta
    Microsoft Online Partner Suppor
    Get Secure! - www.microsoft.com/securit
    This posting is provided "as is" with no warranties and confers no rights
    lynn, Apr 26, 2004
    #4
  5. Hi Lynn,

    Thanks for your feedback.

    Windows Form datagrid is completely different from web form datagrid
    control.

    For winform datagrid, you should handle its DataGridColumnStyle class,
    please refer to 2 articles below:

    http://www.syncfusion.com/faq/winforms/search/480.asp
    http://www.codeproject.com/cs/miscctrl/datagridcomboboxcolumn.asp?target=Dat
    aGridColumnStyle

    Also, for winform datagrid question, I suggest you pasted it in
    microsoft.public.dotnet.framework.windowsforms group. My colleague will
    help you there.

    Thank you for your patience and cooperation. If you have any questions or
    concerns, please feel free to post it in the group. I am standing by to be
    of assistance.

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jeffrey Tan[MSFT], Apr 28, 2004
    #5
  6. Hi Lynn,

    Does my reply make sense to you? Do you still have any concern on this
    issue?

    Please feel free to post. Thanks

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jeffrey Tan[MSFT], Apr 30, 2004
    #6
  7. Lynn

    lynn Guest

    Thanks for your suggestions. I've posted a question under windows forms and I've gotten help from one of your partners

    Lynn
    lynn, Apr 30, 2004
    #7
  8. Hi Lynn,

    I am glad we can help you. If you have aspnet datagrid question, please
    feel free to post here.

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jeffrey Tan[MSFT], May 3, 2004
    #8
    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. =?Utf-8?B?UGF1bA==?=

    datagrid-how to get cell value(hyperlink column)

    =?Utf-8?B?UGF1bA==?=, Oct 12, 2004, in forum: ASP .Net
    Replies:
    9
    Views:
    8,849
    =?Utf-8?B?UGF1bA==?=
    Oct 13, 2004
  2. Replies:
    2
    Views:
    1,307
  3. davetichenor
    Replies:
    1
    Views:
    795
    Eliyahu Goldin
    Oct 30, 2006
  4. Thomasa Gregg
    Replies:
    1
    Views:
    142
    Eliyahu Goldin
    Jun 9, 2004
  5. Dave
    Replies:
    0
    Views:
    919
Loading...

Share This Page