Datagrid - Template or hyperlink Column?

G

Guest

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
 
G

Guest

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
);
}
 
G

Guest

Thats great - thanks

Brad Quinn said:
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
);
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top