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

Hyperlink column in a datagrid

P: n/a
Hi

asp:DataGrid id="YourID" runat="server"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="Sample Column">
<ItemTemplate>
<asp:Hyperlink runat="server" Text='<%
#Container.DataItem("TextVal")%>' NavigateUrl='<%
# "page.aspx?Param1=" & Server.UrlEncode
(Container.DataItem("Val1")) & "&Param2=" &
Server.UrlEncode(Container.DataItem("Val2"))'%>/>
</ItemTemplate>
</asp:TemplateColumn>

</Columns>

Ravikanth[MVP]
-----Original Message-----
I have autogeneratecolumns=true in a datagrid. Is it
possible to have a hyperlink column with a URLfield and
formatstring that are dynamically generated without hard
coding them.

<asp:HyperLinkColumn Text="Select" DataNavigateUrlField=<%=ds.Tables("Codes").Columns(0).ColumnName%>
DataNavigateUrlFormatString=<%=path &"?ID={0}"%
</asp:HyperLinkColumn>

Is there any other way like using a template column for

ahyperlink column?
..
.

Nov 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Thanks. But I want the AutoGenerateColumns=TRUE, and then
create a hyperlink column from a dataset. I don't want to
hardcode the column name. Is is not possible to get it
work this way?
-----Original Message-----
Hi

asp:DataGrid id="YourID" runat="server"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="Sample Column">
<ItemTemplate>
<asp:Hyperlink runat="server" Text='<%
#Container.DataItem("TextVal")%>' NavigateUrl='<%
# "page.aspx?Param1=" & Server.UrlEncode
(Container.DataItem("Val1")) & "&Param2=" &
Server.UrlEncode(Container.DataItem("Val2"))'%>/>
</ItemTemplate>
</asp:TemplateColumn>

</Columns>

Ravikanth[MVP]
-----Original Message-----
I have autogeneratecolumns=true in a datagrid. Is it
possible to have a hyperlink column with a URLfield and
formatstring that are dynamically generated without hard
coding them.

<asp:HyperLinkColumn Text="Select"

DataNavigateUrlField=<%
=ds.Tables("Codes").Columns(0).ColumnName%>
DataNavigateUrlFormatString=<%=path &"?ID={0}"%
</asp:HyperLinkColumn>


Is there any other way like using a template column for

a
hyperlink column?
..
.

.

Nov 17 '05 #2

P: n/a
You could do it that way. Just put the full hyperlink into the database.

Store: <a href="www.msn.com" target="_blank">www.msn.com</a> in your
database and it will show up as www.msn.com in the datagrid.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"dotnet beginner" <sk*****@comsult.com> wrote in message
news:0f****************************@phx.gbl...
Thanks. But I want the AutoGenerateColumns=TRUE, and then
create a hyperlink column from a dataset. I don't want to
hardcode the column name. Is is not possible to get it
work this way?
-----Original Message-----
Hi

asp:DataGrid id="YourID" runat="server"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn HeaderText="Sample Column">
<ItemTemplate>
<asp:Hyperlink runat="server" Text='<%
#Container.DataItem("TextVal")%>' NavigateUrl='<%
# "page.aspx?Param1=" & Server.UrlEncode
(Container.DataItem("Val1")) & "&Param2=" &
Server.UrlEncode(Container.DataItem("Val2"))'%>/>
</ItemTemplate>
</asp:TemplateColumn>

</Columns>

Ravikanth[MVP]
-----Original Message-----
I have autogeneratecolumns=true in a datagrid. Is it
possible to have a hyperlink column with a URLfield and
formatstring that are dynamically generated without hard
coding them.

<asp:HyperLinkColumn Text="Select"

DataNavigateUrlField=<%
=ds.Tables("Codes").Columns(0).ColumnName%>
DataNavigateUrlFormatString=<%=path &"?ID={0}"%
></asp:HyperLinkColumn>

Is there any other way like using a template column for

a
hyperlink column?
..
.

.

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.