Home All Groups Group Topic Archive Search About
Author
18 Jan 2006 6:47 PM
Dave Bareham
I'm fairly new to this so please bear with me!

In an aspx page I have defined a datasource which connects to a SQL
database. I then have defined a datagridview which connects to two fields in
the required table - on is the ID field and the othen contains a caption.

My question is this: Is it possible to generate a series of buttons with the
contents of the caption field as the text for the button? I then want to
cause a navigation to occur to a specific page (passing the ID field as a
parameter) when the button is clicked...so for example, if the select query
returns ...
ID Caption
1  BBC-1
2  BBC-2
3 ITV

When I click on the button with the caption BBC-1 I want to navigate to a
web page (say page.aspx) with a parameter of ?ID=1

I know the basic DGV is working because I can create list of the data in the
table but it's just not in the format I need.

Thanks for your help

Dave

Author
19 Jan 2006 3:39 PM
Doug Salomon
You should be able to add a column of type "HyperLinkField" to your grid.

Get into the Gridview's field editor. (Hover over the gridview, which causes
a little arrow to apear at the top right of the gridview. Click on the arrow,
whcih brings up a grid view tasks pane. Select Edit Columns from that pane.)

In the available fields list on the left, select and add a HyperLinkField.
In the field's properties on the right, fill in the "DataTextField", which
is the database column to which this button should be bound to.
Also fill in the DataNavigateUrlFormatString and DataNavigateUrlFields which
control where you want the link to take your users.

Show quoteHide quote
"Dave Bareham" wrote:

> I'm fairly new to this so please bear with me!
>
> In an aspx page I have defined a datasource which connects to a SQL
> database. I then have defined a datagridview which connects to two fields in
> the required table - on is the ID field and the othen contains a caption.
>
> My question is this: Is it possible to generate a series of buttons with the
> contents of the caption field as the text for the button? I then want to
> cause a navigation to occur to a specific page (passing the ID field as a
> parameter) when the button is clicked...so for example, if the select query
> returns ...
> ID Caption
> 1  BBC-1
> 2  BBC-2
> 3 ITV
>
> When I click on the button with the caption BBC-1 I want to navigate to a
> web page (say page.aspx) with a parameter of ?ID=1
>
> I know the basic DGV is working because I can create list of the data in the
> table but it's just not in the format I need.
>
> Thanks for your help
>
> Dave