DataNavigateUrlFormatString

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default DataNavigateUrlFormatString

    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 working
    DataNavigateUrlFormatString="mypage?val="{0}

    - thanks
    Coder Coder Guest

  2. #2

    Default DataNavigateUrlFormatString

    I have fields bound to a data grid and would like to link
    these fields back to another server to open a document.
    I can hard code the name of the doc and it works fine,
    but I can't get it to accept the variable name.

    Example:
    <asp:HyperLinkColumn DataNavigateUrlField="FullPath"
    DataNavigateUrlFormatString="file:///\\Server1
    \aaa\bbb\ccc\ddd\0000.DWG"

    This works fine and opens the drawing. What I need,
    however, is to open "FullPath", since this changes. I
    can't seem to make this happen.

    Is there anyone that can please help me?

    Thanks
    Ray


    Raymond Guest

  3. #3

    Default Use multiple fields for DataNavigateUrlFormatString SOLUTION!

    I've come up with a pretty good solution to the problem of needing to build
    the NavigateUrl using multiple data values. My solution is partially based
    on code from this article: [url]http://tripleasp.net/tutorial.aspx?NavID=27[/url]

    You need to use a TemplateColumn instead of a HyperLinkColumn. But in order
    to build a TemplateColumn dynamically, you need a class that implements
    ITemplate. I've created such a class which I feel solves this problem quite
    nicely.

    Using the class is as simple as:

    TemplateColumn linkCol = new TemplateColumn();
    linkCol.ItemTemplate = new MultiSourceHyperLinkTemplate("orderItemName",
    "ShowItem.aspx?order={0}&item={1}",
    new string[]{"orderNumber", "orderItemNumber"});
    DataGrid1.Columns.Add(linkCol);

    The above example assumes that orderItemName, orderNumber, and
    orderItemNumber are all column names in the datasource for the datagrid.
    The majority of the work is done by the MultiSourceHyperLinkTemplate class,
    defined below:

    public class MultiSourceHyperLinkTemplate : System.Web.UI.ITemplate
    {
    string m_DataTextField;
    string m_DataNavigateUrlFormatString;
    string[] m_DataNavigateUrlFields;

    public MultiSourceHyperLinkTemplate(string dataTextField, string
    navigateUrlFormatString, string[] navigateUrlFields)
    {
    m_DataTextField = dataTextField;
    m_DataNavigateUrlFormatString = navigateUrlFormatString;
    m_DataNavigateUrlFields = navigateUrlFields;
    }

    private void BindData(object sender, EventArgs e)
    {
    HyperLink link = (HyperLink) sender;
    DataGridItem container = (DataGridItem) link.NamingContainer;
    DataRowView curRow = (DataRowView) container.DataItem;
    link.Text = curRow[m_DataTextField].ToString();
    // evaluate each of the data fields
    string[] navigateUrlValues = new string[m_DataNavigateUrlFields.Length];
    for (int i = 0; i < m_DataNavigateUrlFields.Length; ++i)
    navigateUrlValues[i] = curRow[m_DataNavigateUrlFields[i]].ToString();
    link.NavigateUrl =
    String.Format(System.Globalization.CultureInfo.Inv ariantCulture,
    m_DataNavigateUrlFormatString, navigateUrlValues);

    }

    #region ITemplate Members

    public void InstantiateIn(System.Web.UI.Control container)
    {
    HyperLink link = new HyperLink();
    link.DataBinding += new EventHandler(BindData);
    container.Controls.Add(link);
    }

    #endregion

    #region Property accessors
    string DataTextField { get { return m_DataTextField; } set {
    m_DataTextField = value; } }
    string DataNavigateUrlFormatString { get { return
    m_DataNavigateUrlFormatString; } set { m_DataNavigateUrlFormatString =
    value; } }
    string[] DataNavigateUrlFields { get { return m_DataNavigateUrlFields; }
    set { m_DataNavigateUrlFields = value; } }
    #endregion
    }


    Enjoy!
    -Joshua Flanagan


    Joshua Flanagan Guest

  4. #4

    Default DataNavigateUrlFormatString


    Does anyone know if you can pass multiple column parameters in the
    DataNavigateUrlFormatString for grids?

    My current code is like this and works for a single parameter:

    <asp:HyperLinkColumn
    DataTextField="DTOG1"
    DataNavigateURLField="DTOG1"

    DataNavigateUrlFormatString="javascript:var
    NewWin=window.open('digit_translation.aspx?DTOG1={ 0}',null,'width=800,he
    ight=200,top=100,left=100,scrollbars=no,directorie s=no,status=no,toolbar
    =no,resizable=no');"
    HeaderText="DTOG1" />


    Any help would be much appreciated.


    Cheers,

    Mike



    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Mike P Guest

  5. #5

    Default Re: DataNavigateUrlFormatString

    Tu-Thach,

    How do I convert this to Template column format?

    <asp:HyperLinkColumn
    DataTextField="DTOG1"
    DataNavigateURLField="DTOG1"
    DataNavigateUrlFormatString="javascript:var
    NewWin=window.open('digit_translation.aspx?DTOG1={ 0}',null,'width=800,he
    ight=150,top=100,left=100,scrollbars=no,directorie s=no,status=no,toolbar
    =no,resizable=no');"
    HeaderText="DTOG1" />


    Thanks,

    Mike



    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Mike P Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139