![]() |
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() |
Re: Binding two fields in the DataNavigateUrlFormatString
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() |
Re: Binding two fields in the DataNavigateUrlFormatString
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. <CaffieneRush@gmail.com> wrote in message news:1143147714.586706.100450@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() > |
Re: Binding two fields in the DataNavigateUrlFormatString
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. |
Re: Binding two fields in the DataNavigateUrlFormatString
> 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. <CaffieneRush@gmail.com> wrote in message news:1143152681.674977.177660@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. > |
Re: Binding two fields in the DataNavigateUrlFormatString
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 |
Re: Binding two fields in the DataNavigateUrlFormatString
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 "caffienerush@gmail.com" <CaffieneRush@gmail.com> wrote in message news:1143716793.189565.299810@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 > |
Re: Binding two fields in the DataNavigateUrlFormatString
Thanks. And why did I not think of it?
Regards, Andy |
| All times are GMT. The time now is 02:47 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.