|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
2.0 DatagridView and ButtonsIn 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 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
Help with GridView Update w/ Object Data Source needed
XHTML 1.1 and DIV 1 pixel in height ViewState properties and mapped properties don't work well togethe cache and detailsview, all data controls problem How do I create a custom webcontrol that can have xml inside it's tag? Custom TreeNode for asp.net 2.0 treeview control Multiple onclick Events Menu Control - Templates how to get changed text from web control textbox A bug? Transparent Dynamic Item! |
|||||||||||||||||||||||