embedding <a href > tag in DataGrid

G

Guest

Hello,

I'm new to ASP.NET but have done quite a bit of classic ASP. I need to
drill down to another page from the DataGrid using a record's ID. In classic
ASP, this was quite easy but I can't find anything equivalent in ASP.NET.

For example, I need to go from a page that lists Customers to a page for
CustomerDetails by allowing the user to click anywhere on the row of the
DataGrid.

I've read about using a TemplateColumn and a lable but it doesn't look like
the same functionality. Any help is very much appreciated.

Regards,

ASP.NET Newbie
 
T

tom pester

Hi newbie :)

<asp:DataGrid ID="dg" runat="server" DataSourceID="SqlDataSource1">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="ProductID"
DataNavigateUrlFormatString="details.aspx?id={0}"
Text="More Details"></asp:HyperLinkColumn>
</Columns>
</asp:DataGrid><asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString1 %>"
SelectCommand="SELECT [ProductID], [ProductName], [SupplierID],
[CategoryID], [QuantityPerUnit] FROM [Alphabetical list of products]">
</asp:SqlDataSource>

That code uses the version 2 datasource control but its the hyperlinkColumn
that you are intrested in.


Let me know if it helped you or not...

Cheers,
Tom Pester
 
G

Guest

Tom,

Thank you very much for the example. The HyperLinkColumn tag worked out
perfectly!

Regards,

The Newbie


tom pester said:
Hi newbie :)

<asp:DataGrid ID="dg" runat="server" DataSourceID="SqlDataSource1">
<Columns>
<asp:HyperLinkColumn DataNavigateUrlField="ProductID"
DataNavigateUrlFormatString="details.aspx?id={0}"
Text="More Details"></asp:HyperLinkColumn>
</Columns>
</asp:DataGrid><asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString1 %>"
SelectCommand="SELECT [ProductID], [ProductName], [SupplierID],
[CategoryID], [QuantityPerUnit] FROM [Alphabetical list of products]">
</asp:SqlDataSource>

That code uses the version 2 datasource control but its the hyperlinkColumn
that you are intrested in.


Let me know if it helped you or not...

Cheers,
Tom Pester
Hello,

I'm new to ASP.NET but have done quite a bit of classic ASP. I need
to drill down to another page from the DataGrid using a record's ID.
In classic ASP, this was quite easy but I can't find anything
equivalent in ASP.NET.

For example, I need to go from a page that lists Customers to a page
for CustomerDetails by allowing the user to click anywhere on the row
of the DataGrid.

I've read about using a TemplateColumn and a lable but it doesn't look
like the same functionality. Any help is very much appreciated.

Regards,

ASP.NET Newbie
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top