2.0 DatagridView and Buttons

D

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
 
D

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.
 

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,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top