By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,277 Members | 1,505 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,277 IT Pros & Developers. It's quick & easy.

DataSet bound DataGrid with hyperlinks question

P: n/a
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.
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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.

Nov 18 '05 #2

P: n/a
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" <as****@mailmenot.com> wrote in message
news:Of**************@TK2MSFTNGP10.phx.gbl...
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.

Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.