Link to home
Start Free TrialLog in
Avatar of DStarkey
DStarkey

asked on

ListView (Hide ImageButton if certain criteria = Y)

What I am trying to accomplish is If  Item A = "something" then show the print button else do not show.

I am currently looping through the datatable verifying if a certain code exsits then either show or hide a button. Below is what I have came up with so far but I am getting "Object reference not set to an instance of an object."

Does any one have a working example or some feed back on my code below to get this working?
Thanks for the help...
 
If GetCartItems.Rows(i).Item("D") = "D6Z" Then
                    Dim PH As PlaceHolder = CType(RadListCart.FindControl("PlaceHolder1"), PlaceHolder)
                    Dim Imageb As ImageButton = CType(PH.FindControl("PrintButton2407"), ImageButton)
                    Imageb.Visible = True
                End If
Avatar of rajeeshmca
rajeeshmca
Flag of India image

hi,

can u post your aspx page... what is the error it is throwing now??
Avatar of DStarkey
DStarkey

ASKER

Thanks for the quick response.
Below is a copy of the listview. I did change names etc.. so if something does not look correct then most like it was my alteration. Eveything works fine with my listview I just am trying to make my imagebuttons visable or not.

<telerik:RadListView ID="RadList" runat="server" ItemPlaceholderID="PlaceHolder1" DataKeyNames="i">
<LayoutTemplate>
<fieldset id="RadListCart">
<legend>Order Details</legend>
<asp:Panel ID="HierarchyPanel" runat="server" CssClass="wrapper">
                    <table id="products" cellpadding="3" cellspacing="3" width="90%">
                        <thead>
                            <tr>
                                <th class="expand">
                                </th>
                                <th>
                                    D
                                </th>
                                 <th>
                                   Did
                                </th>
                                <th>
                                    Stock
                                </th>
                                <th>
                                    Item Description
                                </th>
                                <th>
                                 Quantity
                                </th>
                                <th>
                                    UI
                                </th>
                                <th>
                                    UP
                                </th>
                                <th>
                                   TP
                                </th>
                     
                                 <th>
                                Print 1
                                </th>
                                 <th>
                                 Print 2
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr id="PlaceHolder1" runat="server">
                            </tr>
                        </tbody>
                    </table>
                </asp:Panel>
    </fieldset>
</LayoutTemplate>
       <EmptyDataTemplate>
                   <fieldset style="width: 100%">
                       <legend>Cart Item</legend>No items in your Cart.
                   </fieldset>
               </EmptyDataTemplate>
        <ItemTemplate>
       
                            <tr>
                                    <td>
                                     <asp:ImageButton ID="btnd" runat="server" CommandName="Delete" Width="16" Height="16" ImageUrl="~/CMSC-Images/Icons/delete_bin_small.gif" />
                                     <asp:Button ID="Button1" runat="server" Text="edit" CommandName="Edit" />
                                    </td>
                                    <td>
                                     <%#Eval("D")%>
                                    </td>
                                     <td>
                                     <%#Eval("DID")%>
                                    </td>
                                    <td>
                                        <%#Eval("St")%>
                                    </td>
                                    <td>
                                      <%#Eval("No")%>
                                    </td>
                                    <td>
                                        <%#String.Format("{0}", Eval("Qty").ToString())%>
                                    </td>
                                     <td>
                                     <%#Eval("UI")%>
                                    </td>
                                    <td>
                                        <%# Eval("Un", "{0:C}") %>
                                    </td>
                                    <td>
                                        <%#Eval("TP", "{0:C}")%>
                                    </td>
                                    <td>
                                   
                                <asp:ImageButton ID="Pr1" runat="server" ImageUrl="~/CMSC-Images/Icons/printer1.png"
                                       CommandName="Pr1" Width="20" Height="20" AlternateText="Print List" />
                                       
                                    </td>
                                    <td>
                                        <asp:ImageButton ID="Pr2" runat="server" ImageUrl="~/CMSC-Images/Icons/printer1.png"  CommandName="Pr2" Width="20" Height="20" AlternateText="Print List" Visible="false" />
         
                                    </td>
                                </tr>
                     
                            </ItemTemplate>
</telerik:RadListView>
ASKER CERTIFIED SOLUTION
Avatar of guru_sami
guru_sami
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am try to achieve this during Page Load... this might be my issue . Let me play and add to itemdatabound to see if this helps.

 Thanks
Sorry was on a tight schedule... closing ticket