Trouble hiding table row. Based on Querystring

Rate It (2)

Last post 05-12-2008 7:31 PM by jfbomber. 4 replies.

Sort Posts:

  • Trouble hiding table row. Based on Querystring

    05-09-2008, 3:50 PM
    • Loading...
    • jfbomber
    • Joined on 03-14-2008, 9:39 PM
    • Murray
    • Posts 22
      
    1    I am trying to hide a tablerow based on the data of a querystring that is passed from the products.aspx to the productdetails.aspx.
    2 I am using SQL Express, VB Syntax and ASP.NET 2.0
    3
    4
    5 Here is how I am passing the querystring on the products.aspx page:
    6
    7 <asp:HyperLinkField HeaderText="Details" Text="view details" DataNavigateUrlFields="Product_Number" DataNavigateUrlFormatString="productdetails.aspx?ID={0}" >
    8 </asp:HyperLinkField>
    9
    10 Here is the HTML on ProductDetails.aspx that is receiving the querystring information
    11
    12
    13 <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    14 SelectCommand="SELECT * FROM [Products] WHERE (dbo.products.Product_Number = @Product_Number) AND (Product_Quantity > 0)"
    15 ConnectionString="<%$ ConnectionStrings:MaxxReliefDatabaseConnectionString1 %>">
    16 <SelectParameters>
    17 <asp:QueryStringParameter Name="Product_Number" QueryStringField="ID" />
    18 </SelectParameters>
    19 </asp:SqlDataSource>
    20 <asp:FormView runat="server" ID="productdetail" DataSourceID="SqlDataSource1">
    21 <ItemTemplate>
    22 <div id="productdetails">
    23 <table>
    24 <tr>
    25 <td>
    26 <table>
    27 <tr>
    28 <td>
    29 #<asp:Label ID="ProductNumber" runat="server" Text='<%# Bind("Product_Number") %>'></asp:Label></td>
    30 </tr>
    31 <tr>
    32 <td><h3>
    33 <asp:Label ID="ProductName" runat="server" Text='<%# Bind("Product_Name") %>'></asp:Label></h3></td>
    34 </tr>
    35 <tr>
    36 <td><asp:Label ID="ProductCategory" runat="server" Text='<%# Bind("Product_Category") %>'></asp:Label></td>
    37 </tr>
    38
    39 <tr>
    40 <td>
    41 <asp:Label ID="Cost" runat="server" Text='<%# "$" & Eval("Product_Cost") %>'></asp:Label></td>
    42 </tr>
    43 </Table>
    44 </td>
    45 </tr>
    46 </table>
    47 <table id="ProductInformationTable" runat="server">
    48 <tr>
    49 <td>
    50 Description: <asp:Label ID="ProductDescription" runat="server" Text='<%# Bind("Product_Description") %>'></asp:Label>
    51 </td>
    52 </tr>
    53 <tr id="InstructionRow" runat="server" visible="true" >
    54 <td> Instructions: <asp:Label ID="ProductInstructions" runat="server" Text='<%# Bind("Product_Instructions") %>'></asp:Label>
    55 </td>
    56 </tr>
    57 </table>
    58 </div>
    59 </ItemTemplate>
    60 </asp:FormView>
    61 </asp:Content>
    62
    63 So I need to know how to code for the ProductDetails.aspx.vb page. I am trying to hide the <tr> with the ID=”InstructionRow” when the Value of the <label id= “ProductInstructions” querystring = “books”
    64
    65 SQL Database Information:
    66 Products.dbo
    67 ProductID
    68 Product_Number
    69 Product_Category
    70 Product_Cost
    71 Product_Description
    72 Product_Instructions
    73 Etc…
    74
     
    Jason
  • Re: Trouble hiding table row.

    05-09-2008, 4:07 PM
    Answer
    • Loading...
    • Curt_C
    • Joined on 07-23-2003, 8:27 PM
    • Stevens Point, WI - USA
    • Posts 4,015
    • Moderator

    I'd just wrap it in a panel, like this....

    <asp:Panel id="HideMe" runat="server" visible="false">
         <tr><td>.....blah.....</td></tr>
    </asp:Panel>

  • Re: Trouble hiding table row. Based on Querystring

    05-09-2008, 5:15 PM
    • Loading...
    • jfbomber
    • Joined on 03-14-2008, 9:39 PM
    • Murray
    • Posts 22

     I have never used a panel before so I just put it around the tr's and then what do I add for the coding so it knows when the category is books the visibility = false?

    Jason
  • Re: Trouble hiding table row. Based on Querystring

    05-11-2008, 8:58 AM
    • Loading...
    • Rizwan328
    • Joined on 05-25-2006, 6:26 AM
    • Dubai, UAE
    • Posts 238

    Its invalid syntax to  put panel inside table tags. means you are placing rows inside panel it's not valid place whole table inside panel

    If this post helps you, please mark it as Answer.



    Cheers,
    Muhammad Rizwan Javed.
    Software Engineer
    Aim 168 Digital,Dubai, UAE.



  • Re: Trouble hiding table row. Based on Querystring

    05-12-2008, 7:31 PM
    Answer
    • Loading...
    • jfbomber
    • Joined on 03-14-2008, 9:39 PM
    • Murray
    • Posts 22

     This how I figured it out,

        Protected Sub formview1_Databound(ByVal sender As Object, ByVal e As System.EventArgs) Handles formview1.DataBound
            Dim InstructRow As HtmlTableRow = formview1.FindControl("HideTR")
            Dim categlbl As Label = DirectCast(formview1.FindControl("cat"), Label)

            If categlbl.Text = "Books" Then
                InstructRow.Visible = False
            End If

        End Sub

    Jason
Page 1 of 1 (5 items)