473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Binding two fields in the DataNavigateUrlFormatString

Hi,
I would like to bind the hyperlink column but I don't see how to.

I tried somethink like this but instead of showing ID nummbers it shows
"ID=ID"

Any tip is very much appreciated.

Genc
PS:
Code I tested with

aHLCol.DataTextField = "RR_ID"

aHLCol.DataNavigateUrlField = "FILEPATH"

aHLCol.DataNavigateUrlFormatString = "{0}?ID=" &
resultTable.Column("ID").ToString ()

aHLCol.HeaderText = "http:/cnn.com/{0}"

dgSearchResults.Columns.Add(aHLCol)

dgSearchResults.DataSource = resultTable

dgSearchResults.DataBind()
Mar 23 '06 #1
7 17114
I'm guessing you want the url's ID parameter to be set to the ID column
of first row in the results table.

aHLCol.DataNavigateUrlFormatString="{0}?ID=" &
resultTable.Rows(0)("ID").ToString()

Mar 23 '06 #2
Not really, my table has two columns formName and RecordID so I would like
something like the {0} does but for another datafield. eg. below
DataNavigateUrlFormatString="{0}?ID=" &
resultTable.Columns("ID").ToString() updated to each row.

so the DataNavigateUrlFormatString would be


form=f1&ID=1
form=f2&ID=2
form=f3&ID=3

where fn & n values are the values of the formName & its ID in the n-row.

Genc.


<Ca**********@gmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
I'm guessing you want the url's ID parameter to be set to the ID column
of first row in the results table.

aHLCol.DataNavigateUrlFormatString="{0}?ID=" &
resultTable.Rows(0)("ID").ToString()

Mar 23 '06 #3
Hmm, that's a tough one. I believe you can handle the ItemBound event
and modify the url within the hyperlinkcolumn. Never had the occasion
to do what you need but I think the code below would illustrate my
point.

aHLCol.DataNavigateUrlFormatString = "{0}?ID=<RecordID>" 'the real
data would be substituted with the real data during ItemBound.

AddHandler dgSearchResults.ItemBound, AddressOf DGItemBound

dgSearchResults.Columns.Add(aHLCol)
dgSearchResults.DataSource = resultTable
dgSearchResults.DataBind()

'Assume aHLCol is the 1st column in the DataGrid
Sub DGItemBound(sender As Object, e As DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingItem Then

'Replace <RecordID> in the 1st column with the correct
value from resultTable
e.Item.Cells(0).Text =
e.Item.Cell(0).Text.Replace("<RecordID>",
resultTable.Rows(e.Item.ItemIndex)("RecordID"))
End If
End Sub

That is another reason I prefer to work with GridView.
Good luck.

Mar 23 '06 #4
> aHLCol.DataNavigateUrlFormatString = "{0}?ID=<RecordID>" 'the real
data would be substituted with the real data during ItemBound.
Yes ! you are right....

I assumed MS should provide the means without going extra steps b/c already
it provides half of it, the DataNavigateUrl.

I kept trying something like

DataNavigateUrl = "f1, f2" or {"f1","f2"}

thinking that's the most likely MS had implemeted that (following the
pattern)....... As you showed, I could have manipulated the datagrid in
its events as well I could have manipulated the ds adding another column on
the fly before binding etc..,,,,,

Interesting enough, after google it, I read that my assumed "way" of doing
it, it is implemented in .Net 2.0 (I haven't try it though)

What did as a quick solution is that I added another column in my sql
stamement select '<a href= .......' and resolved everything ...........
Thanks a lot and very much appreciated,
Genc.

<Ca**********@gmail.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com... Hmm, that's a tough one. I believe you can handle the ItemBound event
and modify the url within the hyperlinkcolumn. Never had the occasion
to do what you need but I think the code below would illustrate my
point.

aHLCol.DataNavigateUrlFormatString = "{0}?ID=<RecordID>" 'the real
data would be substituted with the real data during ItemBound.

AddHandler dgSearchResults.ItemBound, AddressOf DGItemBound

dgSearchResults.Columns.Add(aHLCol)
dgSearchResults.DataSource = resultTable
dgSearchResults.DataBind()

'Assume aHLCol is the 1st column in the DataGrid
Sub DGItemBound(sender As Object, e As DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingItem Then

'Replace <RecordID> in the 1st column with the correct
value from resultTable
e.Item.Cells(0).Text =
e.Item.Cell(0).Text.Replace("<RecordID>",
resultTable.Rows(e.Item.ItemIndex)("RecordID"))
End If
End Sub

That is another reason I prefer to work with GridView.
Good luck.

Mar 25 '06 #5
Hi Genc,

Please post the other way of binding multiple parameters to
DataNavigateUrl because I think my idea of replacing the parameter
during ItemBound is a bit of a bodge.

Regards,
Andy

Mar 30 '06 #6
You can do this
<asp:HyperLink runat="server" Text="View"
NavigateUrl='<%# "urpage.aspx?ID=" & _
Container.DataItem("urID") & _
"&showpage=" & Container.DataItem("secondID")
%>' />
Hope that helps
Patrick
"ca**********@gmail.com" <Ca**********@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
Hi Genc,

Please post the other way of binding multiple parameters to
DataNavigateUrl because I think my idea of replacing the parameter
during ItemBound is a bit of a bodge.

Regards,
Andy

Mar 30 '06 #7
Thanks. And why did I not think of it?

Regards,
Andy

Mar 30 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Coder Coder | last post by:
Hi I want the DataNavigateUrlFormatString value to be of a couple of different variables such as: DataNavigateUrlFormatString="mypage?val={0}&val2={1} where now I have the following...
2
by: TJS | last post by:
how can I dynamically set the value of DataNavigateUrlFormatString in a hyperlink column I have the value to use, I need the correct syntax . "<%= %>" isn't working <asp:HyperLinkColumn...
0
by: RobT | last post by:
Hi, I've been using the DataGrid control in my ASP.NET web page. The page is used to search for records in the database. The control is bound to a DataSource and gets populated ok. I am also...
19
by: Simon Verona | last post by:
I'm not sure if I'm going down the correct route... I have a class which exposes a number of properties of an object (in this case the object represents a customer). Can I then use this...
3
by: msuk | last post by:
All, I am using a datagrid on a 1.1 .aspx page that has a hyperlink column. I am using 'DataNavigateUrlFormatString' to set the URL to browse to once the user clicks on the link i.e. ...
2
by: bmayer | last post by:
I am using a detail view and binding it to a sql data source (at some point in the future it will be an object data source). I have seen the article "Working with Data is ASP.NET 2.0 ::...
2
by: Ixnay | last post by:
Thanks in advance for any help you can give me on this. I am trying to include the value from a request.querystring in the DataNavigateUrlFormatString I am able to include one of the values...
2
by: Vincent | last post by:
Hi, I have a problem when I put the 3rd field into a hyperlink field it does not show up. Here's my example: This works and the url is: http://gl.aspx?whs=1&dept=02 <asp:HyperLinkField...
1
by: dorkboy | last post by:
Hi all, I am a newbie using VB.net in VS 2008. I took over a vb.net winform application that has a binding navigator in it. The users wanted to add 2 new fields to the form. I added the new...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.