Query string and Parameter Passing Problem

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Query string and Parameter Passing Problem

    Hi

    In the context of a Master/Detail scenario, I am having trouble figuring
    out the correct syntax for passing a parameter in a query string in a
    HyperLink Column, but the parameter is coming from a seperate bound column,
    which is not visible and so cannot itself be used as the hyperlink column

    If I want to pass the parameter from my Hyperlink column, it is fine,

    DataNavigateUrlFormatString="detailsPage.aspx?ID={ 0}"


    but how do I reference my invisible bound column, that is, the unique 'ID'
    one,

    <asp:BoundColumn HeaderText="ID" DataField="ID" Visible="False" />

    and pass it as a parameter in the query string

    DataNavigateUrlFormatString="detailsPage.aspx?ID={ 0}"

    My Datagrid is as follows

    <asp:DataGrid ID="dgrdMenu" Runat="Server"

    AutoGenerateColumns="false">

    <Columns>
    <asp:BoundColumn HeaderText="ID" DataField="ID" Visible="False"
    />
    <asp:BoundColumn HeaderText="Code" DataField="Code" />
    <asp:HyperLinkColumn
    HeaderText="Product Description"
    DataNavigateUrlField="Description"
    DataNavigateUrlFormatString="detailsPage.aspx?ID={ 0}"
    DataTextField="Description"
    Target="_new" />
    <asp:BoundColumn HeaderText="Price" DataField="Retail"/>
    </Columns>

    </asp:DataGrid>

    and my SQL string is "Select ID, Code, Description, Retail from
    Pricelist0804 WHERE

    Description LIKE '%' + @name + '%' ";

    I would be grateful if anyone could give me the exact syntax

    --
    Message posted via [url]http://www.dotnetmonster.com[/url]
    Paul Gray via DotNetMonster.com Guest

  2. Similar Questions and Discussions

    1. Multi-parameter query string in hyperlink column...
      I have found some postings on multi-parameter hyperlinks. But none of them involve calling a javascript function. I have almost got the NavigateUrl...
    2. Passing XML in a string parameter
      We have a parameter to a webmethod that is defined as a string. We expect to pass XML in this string. What we've found out is that the .Net web...
    3. Passing a Large String as a parameter to a web service
      Hello I have a situation where I might pass a large string as a parameter to a webservice. The string size could go upto 100 MB. Is there a...
    4. Using query string to pass a value to a stored procedure parameter
      All, I want to push on a form button in an HTML page and pass a query string to the ASP.NET page I’m opening. That query string has the...
    5. Passing Unicode String as Web Method Parameter
      All web requests and responses by default under ASP.NET are sent as unicode and are encoded as unicode UTF8. This can be changed in the...
  3. #2

    Default Query string and Parameter Passing Problem

    Hi Paul,

    If you want to pass ID rather than Description as query
    string to hyperline, you can do it in
    datagrid_ItemDataBound event:

    if (e.Item.ItemType == ListItemType.Item ||
    e.Item.ItemType == ListItemType.AlternatingItem )
    {
    DataRowView drv = (DataRowView)e.Item.DataItem;
    HyperLink link = (HyperLink)e.Item.Cells
    [2].Controls[0];
    link.NavigateUrl="detailsPage.aspx?ID=" + drv
    ["ID"].ToString();
    }


    HTH

    Elton Wang
    [email]elton_wang@hotmail.com[/email]

    >-----Original Message-----
    >Hi
    >
    >In the context of a Master/Detail scenario, I am having
    trouble figuring
    >out the correct syntax for passing a parameter in a query
    string in a
    >HyperLink Column, but the parameter is coming from a
    seperate bound column,
    >which is not visible and so cannot itself be used as the
    hyperlink column
    >
    >If I want to pass the parameter from my Hyperlink column,
    it is fine,
    >
    >DataNavigateUrlFormatString="detailsPage.aspx?ID= {0}"
    >
    >
    >but how do I reference my invisible bound column, that
    is, the unique 'ID'
    >one,
    >
    > <asp:BoundColumn HeaderText="ID" DataField="ID"
    Visible="False" />
    >
    >and pass it as a parameter in the query string
    >
    >DataNavigateUrlFormatString="detailsPage.aspx?ID= {0}"
    >
    >My Datagrid is as follows
    >
    ><asp:DataGrid ID="dgrdMenu" Runat="Server"
    >
    > AutoGenerateColumns="false">
    >
    > <Columns>
    > <asp:BoundColumn HeaderText="ID"
    DataField="ID" Visible="False"
    >/>
    > <asp:BoundColumn HeaderText="Code"
    DataField="Code" />
    > <asp:HyperLinkColumn
    > HeaderText="Product Description"
    > DataNavigateUrlField="Description"
    >
    DataNavigateUrlFormatString="detailsPage.aspx?ID={ 0}"
    > DataTextField="Description"
    > Target="_new" />
    > <asp:BoundColumn HeaderText="Price"
    DataField="Retail"/>
    > </Columns>
    >
    > </asp:DataGrid>
    >
    >and my SQL string is "Select ID, Code, Description,
    Retail from
    >Pricelist0804 WHERE
    >
    >Description LIKE '%' + @name + '%' ";
    >
    >I would be grateful if anyone could give me the exact
    syntax
    >
    >--
    >Message posted via [url]http://www.dotnetmonster.com[/url]
    >.
    >
    Elton W Guest

  4. #3

    Default Re: Query string and Parameter Passing Problem

    Thanks Elton, I will try that

    --
    Message posted via [url]http://www.dotnetmonster.com[/url]
    Paul Gray via DotNetMonster.com 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