You can't do it using a normal bound column.
You need a template column.
Then in the dg_ItemDataBound event you create an instance of the hyperlink
and find it using FindControl and then set its properties.
In this case the dg is bound to a collection and the index of the collection
equals the index of the grid. So you can always identify whcih row you are
on.
================================================== =====================
<asp:TemplateColumn SortExpression="myColumn" HeaderText="My Header">
<ItemTemplate>
<asp:Hyperlink id="hylMyColumn"
runat="server"></asp:Hyperlink>
</ItemTemplate>
</asp:TemplateColumn>
================================================== =====================
Private Sub dg_ItemDataBound(ByVal sender As Object, ByVal e As
DataGridItemEventArgs) Handles dg.ItemDataBound
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then
'need to take paging into account!
Dim mIndex As Integer = CType(sender, DataGrid).PageSize *
CType(sender, DataGrid).CurrentPageIndex + e.Item.ItemIndex
'set hyperlinks values:
'Note: in the HTML the is required because the grid cells will
change shape w/o it when there is no data.
Dim ohylMyColumn As HyperLink =
CType(e.Item.FindControl("hylMyColumn"), HyperLink)
ohylMyColumn.NavigateUrl =
"javascript
:LeftSideWin('ViewSomePage.aspx?Key =" & mCollection(mIndex).key &
_
"&KeyType=" & mCollection(mIndex).keytype & "','MyScreen');"
oHylInvNumber.Text = mCollection(mIndex).MyDescription
End If
End Sub
================================================== =====================
--
Joe Fallon
"carlor" <ca****@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
Hi there,
I have a datagrid that is bound to a datasource. The grid has a hyperlink
column and I want to generate the URL using the URL Field and URL Format
String fields in the Property Builder.
The problem I'm running into is trying to generate the URL with more than
one URL Field entry. I need to have more than field but I can't figure out
how to add more than one field in the URL Field textbox. Is it possible?
I would want the URL Format String to look something like...
MyURL.aspx?field_1={0}&field_2={1}
Any help would be greatly appreciated.
Carlo.