Datagrid - Template or hyperlink Column?

Discussion in 'ASP .Net' started by =?Utf-8?B?TG1jRQ==?=, Mar 10, 2005.

  1. Hi,

    I have created a datagrid with a template column containing a datalist.
    However, I need the text within the datalist to display as a hyperlink. Eack
    of the links will point to another form with 2 parameters passed in.

    Has anyone any ideas how to add the hyperlink?

    Many Thanks
    =?Utf-8?B?TG1jRQ==?=, Mar 10, 2005
    #1
    1. Advertising

  2. Template column;

    <ItemTemplate>
    <asp:HyperLink runat="server"
    Text='<%# DataBinder.Eval(Container,"DataItem.TextField") %>'
    NavigateUrl='<%# BuildUrl(
    (int)DataBinder.Eval(Container,"DataItem.IntField"),
    (string)DataBinder.Eval(Container,"DataItem.StringField") ) %'>
    </asp:HyperLink>
    </ItemTemplate>

    Code behind;

    protected string BuildUrl( int field1, string field2 )
    {
    // TODO - Do whatever you need to do to build your Url
    return string.Format( "{0}?field1={1}&field2={2}", baseUrl, field1, field2
    );
    }

    "LmcE" wrote:

    > Hi,
    >
    > I have created a datagrid with a template column containing a datalist.
    > However, I need the text within the datalist to display as a hyperlink. Eack
    > of the links will point to another form with 2 parameters passed in.
    >
    > Has anyone any ideas how to add the hyperlink?
    >
    > Many Thanks
    >
    >
    =?Utf-8?B?QnJhZCBRdWlubg==?=, Mar 10, 2005
    #2
    1. Advertising

  3. Thats great - thanks

    "Brad Quinn" wrote:

    > Template column;
    >
    > <ItemTemplate>
    > <asp:HyperLink runat="server"
    > Text='<%# DataBinder.Eval(Container,"DataItem.TextField") %>'
    > NavigateUrl='<%# BuildUrl(
    > (int)DataBinder.Eval(Container,"DataItem.IntField"),
    > (string)DataBinder.Eval(Container,"DataItem.StringField") ) %'>
    > </asp:HyperLink>
    > </ItemTemplate>
    >
    > Code behind;
    >
    > protected string BuildUrl( int field1, string field2 )
    > {
    > // TODO - Do whatever you need to do to build your Url
    > return string.Format( "{0}?field1={1}&field2={2}", baseUrl, field1, field2
    > );
    > }
    >
    > "LmcE" wrote:
    >
    > > Hi,
    > >
    > > I have created a datagrid with a template column containing a datalist.
    > > However, I need the text within the datalist to display as a hyperlink. Eack
    > > of the links will point to another form with 2 parameters passed in.
    > >
    > > Has anyone any ideas how to add the hyperlink?
    > >
    > > Many Thanks
    > >
    > >
    =?Utf-8?B?TG1jRQ==?=, Mar 10, 2005
    #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. damonf
    Replies:
    2
    Views:
    3,867
    damonf
    Oct 24, 2003
  2. =?Utf-8?B?V2FyYW4=?=

    HyperLink Column and Button Column in a DataGrid

    =?Utf-8?B?V2FyYW4=?=, Aug 9, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    594
    =?Utf-8?B?V2FyYW4=?=
    Aug 9, 2005
  3. =?Utf-8?B?ZGF2aWQ=?=
    Replies:
    11
    Views:
    998
    deandany
    Jul 17, 2006
  4. davetichenor
    Replies:
    1
    Views:
    808
    Eliyahu Goldin
    Oct 30, 2006
  5. Dave
    Replies:
    0
    Views:
    927
Loading...

Share This Page