Community discussion forum

Hypelink field in gridview

  • 8 months ago

    hi,

    I  have  3 tables in my database  1.Prouct(ProductId,Productname)

                                                    2.Problems(ProductId,PoblemID,ProblemDesc)

                                                    3. Solutions(ProblemId,Solutiondesc)

     

    Now in my first page I have to display all the Productnames in a gridview with hyperlink to each product name.

    On clicking  th productname i should pass the product id of the product to second page.

    In second page i should display the problems relateds to product id 1 and so.
    In the gridview i Used Hyperlinkfield.Now how do i Pass the product id  of the product to second page during the navigation?

     
     

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 8 months ago

    Assuming you already have your datatable binded to your gridview, instead of using hyperlink, try this...

    <asp:TemplateField HeaderText="Product Id">
        <ItemTemplate>
     <a href="page2.aspx?prod_id=<%# DataBinder.Eval(Container.DataItem, "ProductId") %>">
         <asp:Label ID="lblProductId" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ProductId") %>'></asp:Label></a></ItemTemplate>
    </asp:TemplateField>

    Here, i'm passing the product id through the querystring. in your page 2, just add:

    String strProdId = Request.QueryString["prod_id"].ToString()

    Hmm, don't know if this can help... Please tell me so, if it did. Even if it didn't, just let me know.. If I misunderstood, please clarify, ü

  • 8 months ago

     hi,

     It worked for me.thanks a lot.


     

  • 8 months ago

    ur welcome, ü

Post a reply

Enter your message below

Sign in or Join us (it's free).