Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In DetailsView in VS 2005 issue with DataNavigateUrlFormatString?

Status
Not open for further replies.

jbailey268

Programmer
May 25, 2005
51
US
This is a Web ap.
I would like to change the path dynamically at runtime
via

DetailsView1.Fields.Item(0).DataNavigateUrlFormatString = "&file=\\server1\main\data\HOME.fof\ImageArchive\{0}"

to something else as follows

DetailsView1.Fields.Item(0).DataNavigateUrlFormatString = "&file=\\server1\main\data\REMOTE.fof\ImageArchive\{0}"

(note the switch from HOME to REMOTE)

First of All I can't even find the syntax that doesn't yield an error. (blue underline)
I can see it in the watch window in debug mode; but can't copy and paste it's text viewer text description into my code.

Also is it even possible? Maybe it's a read only property...

Other hints I've seen on the internet all seem to involve some archane HTML code. I need to do it in regular code behind.
Can it be set on the fly? Thanks
 
I would use a template rather than the built-in LinkField
Code:
<asp:DetailsView id=DV ... OnItemDataBound="DV_ItemDataBound">
   <ItemTemplate>
      <asp:HyperLink id="MyLink" Text="Click Me"/>
   <ItemTemplate>
</asp:DetailsView>

protect void DV_ItemDataBound(object sender, ItemDataBoundEventArgs e)
{
   if(e.Item.ItemType == DataItem)
   {
      //you may use a different object then dataview/datatable
      DataViewRow row = (DataViewRow)e.Item.DataItem;

      HyperLink link = (HyperLink)e.Item.FindControl("MyLink");
      link.NavigateUrl = "place url here";
   }
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top