DataGrid

Discussion in 'ASP .Net Web Controls' started by Raja Balaji R, Oct 21, 2003.

  1. hi

    i have table emp which contains field eno, ename, esal.

    i displaying it in a datagrid

    eno column is hyperlinkcolumn
    ename, esal are normal bound column

    i want that eno hyperlinkcolumn href value to be in
    form "sample.aspx?eno=1&ename=rock", 1 is the value of
    eno column(hyper column) value and rock is the ename column
    (bound column).

    how to give URL, URL field, URL format string values in
    datagrid columns property dialog.

    thanks in advance
     
    Raja Balaji R, Oct 21, 2003
    #1
    1. Advertising

  2. Hi Raja,

    You need to use the ItemDataBound event.

    I created a query using the Pubs database as follows:
    "SELECT au_id, au_lname, au_fname FROM authors"

    I then added a datagrid with a hyperlink column plus autogenerate columns.

    I then use string manipulation to create the hyperlink as follows.

    Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    DataGrid1.ItemDataBound

    If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
    ListItemType.AlternatingItem Then

    CType(e.Item.Cells(0).Controls(0), HyperLink).NavigateUrl =
    "http://" & e.Item.DataItem("au_id") & "?lname=" &
    e.Item.DataItem("au_lname") & "&fname=" & e.Item.DataItem("au_fname")

    CType(e.Item.Cells(0).Controls(0), HyperLink).Text = "http://"
    & e.Item.DataItem("au_id") & "?lname=" & e.Item.DataItem("au_lname") &
    "&fname=" & e.Item.DataItem("au_fname")

    End If

    End Sub

    ----
    I hope this helps.

    Thank you, Mike
    Microsoft, ASP.NET Support Professional

    Microsoft highly recommends to all of our customers that they visit the
    http://www.microsoft.com/protect site and perform the three straightforward
    steps listed to improve your computer’s security.

    This posting is provided "AS IS", with no warranties, and confers no rights.


    --------------------
    > Content-Class: urn:content-classes:message
    > From: "Raja Balaji R" <>
    > Sender: "Raja Balaji R" <>
    > Subject: DataGrid
    > Date: Tue, 21 Oct 2003 02:07:24 -0700
    > Lines: 19
    > Message-ID: <0acc01c397b2$bdeb6780$>
    > MIME-Version: 1.0
    > Content-Type: text/plain;
    > charset="iso-8859-1"
    > Content-Transfer-Encoding: 7bit
    > X-Newsreader: Microsoft CDO for Windows 2000
    > Thread-Index: AcOXsr3oKdd8sO/MTBmykWz0QVZOfw==
    > X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
    > Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
    > Path: cpmsftngxa06.phx.gbl
    > Xref: cpmsftngxa06.phx.gbl

    microsoft.public.dotnet.framework.aspnet.webcontrols:15524
    > NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
    > X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
    >
    > hi
    >
    > i have table emp which contains field eno, ename, esal.
    >
    > i displaying it in a datagrid
    >
    > eno column is hyperlinkcolumn
    > ename, esal are normal bound column
    >
    > i want that eno hyperlinkcolumn href value to be in
    > form "sample.aspx?eno=1&ename=rock", 1 is the value of
    > eno column(hyper column) value and rock is the ename column
    > (bound column).
    >
    > how to give URL, URL field, URL format string values in
    > datagrid columns property dialog.
    >
    > thanks in advance
    >
    >
     
    Mike Moore [MSFT], Oct 21, 2003
    #2
    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. Dave
    Replies:
    0
    Views:
    475
  2. BK Kim

    datagrid in datagrid

    BK Kim, Feb 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    570
    Alvin Bruney [MVP]
    Mar 2, 2004
  3. =?Utf-8?B?U3VyZXNo?=
    Replies:
    0
    Views:
    546
    =?Utf-8?B?U3VyZXNo?=
    Mar 2, 2004
  4. Brian K. Williams
    Replies:
    0
    Views:
    561
    Brian K. Williams
    Mar 2, 2004
  5. Andreas Klemt
    Replies:
    0
    Views:
    333
    Andreas Klemt
    Oct 8, 2003
Loading...

Share This Page