Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Binding two fields in the DataNavigateUrlFormatString

Reply
Thread Tools

Binding two fields in the DataNavigateUrlFormatString

 
 
genc_ymeri
Guest
Posts: n/a
 
      03-23-2006
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()


 
Reply With Quote
 
 
 
 
CaffieneRush@gmail.com
Guest
Posts: n/a
 
      03-23-2006
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()

 
Reply With Quote
 
 
 
 
genc_ymeri
Guest
Posts: n/a
 
      03-23-2006
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.




<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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()
>



 
Reply With Quote
 
CaffieneRush@gmail.com
Guest
Posts: n/a
 
      03-23-2006
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.

 
Reply With Quote
 
genc_ymeri
Guest
Posts: n/a
 
      03-25-2006
> 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.

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.
>



 
Reply With Quote
 
caffienerush@gmail.com
Guest
Posts: n/a
 
      03-30-2006
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

 
Reply With Quote
 
Patrick.O.Ige
Guest
Posts: n/a
 
      03-30-2006
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


"(E-Mail Removed)" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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
>



 
Reply With Quote
 
caffienerush@gmail.com
Guest
Posts: n/a
 
      03-30-2006
Thanks. And why did I not think of it?

Regards,
Andy

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataNavigateUrlFormatString Mike P ASP .Net 2 10-10-2008 07:16 AM
Binding two fields in the DataNavigateUrlFormatString genc_ymeri ASP .Net Web Controls 7 03-30-2006 05:22 PM
Newbie - Reading a file with delimited fields, storing first two fields in a hash AMT2K5 Perl Misc 1 11-08-2005 01:06 AM
DataNavigateUrlFormatString Coder Coder ASP .Net 1 08-06-2003 12:22 AM
DataNavigateUrlFormatString Raymond ASP .Net 0 07-11-2003 04:27 PM



Advertisments