I need to use a gridview that has a hyperlink as one of the fields.
The fields need to be databound. When the user presses the hyperlink,
I do not want to navigate to another page. I want to store the ID of
the row. The user will then use buttons on the page that represents
what they want to do to that row. Delete, update, etc. Here is the
code for the gridview.
NOTE: Removed some parts of this, like datasourceID and things.
Didn't format well on the post
<cc1:GridViewSD ID="gvwORLList" runat="server" AllowPaging="True"
AllowSorting="True"
ArrowDownUrl="~/images/sortdescending.gif" rowUpUrl="~/images/
sortascending.gif"
AutoGenerateColumns="False" CellPadding="4"
HorizontalAlign="Left" />
<Columns>
<asp:BoundField DataField="template_name"
HeaderText="Record Title" SortExpression="template_name" />
<asp:BoundField DataField="CALENDAR_year"
HeaderText="Year" SortExpression="CALENDAR_year" />
<asp:BoundField DataField="Column1" HeaderText="Status"
ReadOnly="True" SortExpression="Column1" />
</Columns>
</cc1:GridViewSD>
> I need to use a gridview that has a hyperlink as one of the fields.
> The fields need to be databound. When the user presses the hyperlink,
[quoted text clipped - 21 lines]
> </Columns>
> </cc1:GridViewSD>
Rather than doing it that way, have you considered enabling the
AutoGenerateEdit or Select buttons on the GridView? It will allow you
to edit/update/delete the items of that row when selected?
Alternatively, you could create an ItemTemplate, and then simply embed
whatever server side control you want. When the user presses your
link, you could then enable/disable the controls that you have for
that ItemTemplate on the server side. Here is an example using an
Image Button, which you can change to a hyperlink for your case.
<ItemTemplate>
<ul>
<li>
<asp:ImageButton ID="ImageButton1"
runat="server" OnClick="FormatImageNavigation" ImageUrl='<%#
(string) FormatImageUrl( (int) Eval("ID"),(int) Eval("TYPE_ID"),
(string) Eval("NAME"),(string) Eval("PATH") ) %>' Width="200"
Height="250"/>
</li>
</ul>
</ItemTemplate>
</ItemTemplate>
Ralf - 25 Jul 2007 17:36 GMT
Thx for the response. The commands the user can do are actually
update, rename, view, and submit. I don't want the grid to have 4
different buttons beside each row. I want to store the ID of the row
when the user selects the row. Are you telling me I can setup the
hyperlink as an itemtemplate and just set the onclick event to call
the function to store the ID for future use of pressing the buttons?
David Wier - 25 Jul 2007 18:22 GMT
Sure - use the OnSelectedIndexChanged event - assign the row:
Dim row As GridViewRow = MyGridView.SelectedRow
Dim intRow as Integer=Row.RowIndex
(or something close to this)

Signature
David Wier
MVP/ASPInsider
http://aspnet101.com
http://iWritePro.com
> Thx for the response. The commands the user can do are actually
> update, rename, view, and submit. I don't want the grid to have 4
> different buttons beside each row. I want to store the ID of the row
> when the user selects the row. Are you telling me I can setup the
> hyperlink as an itemtemplate and just set the onclick event to call
> the function to store the ID for future use of pressing the buttons?
lee whitbeck - 25 Jul 2007 20:15 GMT
On Jul 25, 12:22 pm, "David Wier" <davidw...@davidwier.nospam.com>
wrote:
> Sure - use the OnSelectedIndexChanged event - assign the row:
> Dim row As GridViewRow = MyGridView.SelectedRow
[quoted text clipped - 13 lines]
>
> - Show quoted text -
Yes.. That is one way of doing it.
Ralf - 26 Jul 2007 14:58 GMT
I get errors b/c it seems to be expecting a URL to be assigned.