WebControls.DataGrid

M

Martin Dew

I have a HyperLinkColumn inside my Databound grid on a page, I have been
using the URL Field property set to a field name in my bound data, and then
using the URL Format String as dbClientconn.aspx?searchID={0} and all works
perfectly, however I need to set this to have to fields values in the
string,
something like;

URL Field: ClientConnectionField, ClientCustomerRefField
URL Format String: dbclientconn.aspx?searchID={0}&custref={1}

However this does not work, it would appear you can only use one format
placing {0}. Can someone tell me if you can do it and how ?

Thanks

Martin
 
J

Joe Fallon

You are correct.
You are limited to 1.
============================================================
Here is how I get around it:
============================================================
In my grid I use this:
============================================================
<asp:TemplateColumn SortExpression="statustext" HeaderText="Status">
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:Hyperlink id="hylStatus" runat="server"></asp:Hyperlink>
</ItemTemplate>
</asp:TemplateColumn>

============================================================
In my code behind I use this:

Private Sub dg_ItemDataBound(ByVal sender As System.Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles dg.ItemDataBound

If e.Item.ItemType = ListItemType.Item Or 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 Status hyperlink
Dim oHylStatus As HyperLink = CType(e.Item.FindControl("hylStatus"),
HyperLink)

'hide the link if the Status is "xyz", otherwise show it:
If myBizObj(mIndex).status = "xyz" Then
oHylStatus.NavigateUrl = ""
Else
'custom javascript function for opening a new window.
oHylStatus.NavigateUrl = "javascript:NewWin('ViewStatus.aspx?Key=" &
myBizObj(mIndex).key & "&Type=" & myBizObj(mIndex).type &
"','MyStatus',0,0,640,480);"
End If

oHylStatus.Text = myBizObj(mIndex).statustext
....
============================================================
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top