Query string and Parameter Passing Problem

Discussion in 'ASP .Net Datagrid Control' started by Elton W, May 12, 2005.

  1. Elton W

    Elton W Guest

    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



    >-----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 http://www.dotnetmonster.com
    >.
    >
     
    Elton W, May 12, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. moondaddy
    Replies:
    4
    Views:
    571
    moondaddy
    Sep 12, 2007
  2. Replies:
    0
    Views:
    1,250
  3. Bobby Edward
    Replies:
    1
    Views:
    379
    imransyed63
    Apr 24, 2009
  4. Mister B
    Replies:
    8
    Views:
    568
    Nick Keighley
    Aug 26, 2010
  5. nick
    Replies:
    1
    Views:
    477
    David Mark
    Feb 13, 2011
Loading...

Share This Page