DataSet bound DataGrid with hyperlinks question

Discussion in 'ASP .Net' started by Alex, Apr 15, 2004.

  1. Alex

    Alex Guest

    I'm reposting my issue with some more info.

    I would like to use a DataGrid to display my DataSet.
    My DataSet is from a table in a SQL DB.
    Both columns in the table are strings.

    I would like it to look like the following where the URL column is
    clickable.

    ---------------------------------------------
    name | URL
    ---------------------------------------------
    Microsoft | http:\\www.microsoft.com
    ---------------------------------------------
    CNN | http:\\www.cnn.com
    ---------------------------------------------

    I would like to use data binding.

    However if I'm using a data bound columns I can't get the hyperlink
    functionality. Or I don't know how do this. Is there a simple formatting
    trick?

    If I use a hyperlink column I can't use data binding.
     
    Alex, Apr 15, 2004
    #1
    1. Advertising

  2. Alex

    ashish Guest

    Look into how to to create template columns in the DataGrid to customize
    appearance

    for example

    <asp:DataGrid id="DataGrid1" runat="server">
    <columns>
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:label name="lblname" runat="server"
    text='<%# DataBinder.Eval(Container.DataItem,"ColumnName") %>' >
    </asp:label>
    <asp:HyperLink id=lnkImage Runat="server" NavigateUrl='<%#
    DataBinder.Eval(Container.DataItem,"Columnlink") %>'></asp:HyperLink>
    </ItemTemplate>
    </asp:TemplateColumn>
    </columns>
    </asp:datagrid>


    hth
    -ashish

    Alex wrote:

    > I'm reposting my issue with some more info.
    >
    > I would like to use a DataGrid to display my DataSet.
    > My DataSet is from a table in a SQL DB.
    > Both columns in the table are strings.
    >
    > I would like it to look like the following where the URL column is
    > clickable.
    >
    > ---------------------------------------------
    > name | URL
    > ---------------------------------------------
    > Microsoft | http:\\www.microsoft.com
    > ---------------------------------------------
    > CNN | http:\\www.cnn.com
    > ---------------------------------------------
    >
    > I would like to use data binding.
    >
    > However if I'm using a data bound columns I can't get the hyperlink
    > functionality. Or I don't know how do this. Is there a simple formatting
    > trick?
    >
    > If I use a hyperlink column I can't use data binding.
    >
    >
     
    ashish, Apr 15, 2004
    #2
    1. Advertising

  3. Alex

    Alex Guest

    Thanks!

    I didn't realize that I can mix and match.
    <Columns>
    <asp:BoundColumn DataField="Name" HeaderText="col
    Name"></asp:BoundColumn>
    <asp:TemplateColumn HeaderText="Link">
    <ItemTemplate>
    <asp:HyperLink id=lnk Runat="server"
    NavigateUrl='<%#DataBinder.Eval(Container.DataItem,"mylink")%>'><%#DataBinde
    r.Eval(Container.DataItem,"mylink")%></asp:HyperLink>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>

    "ashish" <> wrote in message
    news:...
    > Look into how to to create template columns in the DataGrid to customize
    > appearance
    >
    > for example
    >
    > <asp:DataGrid id="DataGrid1" runat="server">
    > <columns>
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <asp:label name="lblname" runat="server"
    > text='<%# DataBinder.Eval(Container.DataItem,"ColumnName") %>' >
    > </asp:label>
    > <asp:HyperLink id=lnkImage Runat="server" NavigateUrl='<%#
    > DataBinder.Eval(Container.DataItem,"Columnlink") %>'></asp:HyperLink>
    > </ItemTemplate>
    > </asp:TemplateColumn>
    > </columns>
    > </asp:datagrid>
    >
    >
    > hth
    > -ashish
    >
    > Alex wrote:
    >
    > > I'm reposting my issue with some more info.
    > >
    > > I would like to use a DataGrid to display my DataSet.
    > > My DataSet is from a table in a SQL DB.
    > > Both columns in the table are strings.
    > >
    > > I would like it to look like the following where the URL column is
    > > clickable.
    > >
    > > ---------------------------------------------
    > > name | URL
    > > ---------------------------------------------
    > > Microsoft | http:\\www.microsoft.com
    > > ---------------------------------------------
    > > CNN | http:\\www.cnn.com
    > > ---------------------------------------------
    > >
    > > I would like to use data binding.
    > >
    > > However if I'm using a data bound columns I can't get the hyperlink
    > > functionality. Or I don't know how do this. Is there a simple formatting
    > > trick?
    > >
    > > If I use a hyperlink column I can't use data binding.
    > >
    > >
     
    Alex, Apr 15, 2004
    #3
    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. Alex
    Replies:
    0
    Views:
    424
  2. sunil panda

    Lower bound & Upper bound

    sunil panda, Dec 25, 2003, in forum: Java
    Replies:
    9
    Views:
    7,264
    thushara wijeratna
    Oct 7, 2008
  3. Rhiner Dan
    Replies:
    1
    Views:
    749
    Mike Wahler
    Mar 27, 2005
  4. Mario Krsnic
    Replies:
    0
    Views:
    386
    Mario Krsnic
    Jun 23, 2006
  5. Whugster

    typed DataSet-bound DataGrid sorting

    Whugster, Jun 29, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    127
    Whugster
    Jun 29, 2004
Loading...

Share This Page