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.FindCont rol("Place Holder1"), PlaceHolder)
Dim Imageb As ImageButton = CType(PH.FindControl("Prin tButton240 7"), ImageButton)
Imageb.Visible = True
End If
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(
Dim PH As PlaceHolder = CType(RadListCart.FindCont
Dim Imageb As ImageButton = CType(PH.FindControl("Prin
Imageb.Visible = True
End If
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="PlaceHo lder1" 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/Ic ons/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/Ic ons/printe r1.png"
CommandName="Pr1" Width="20" Height="20" AlternateText="Print List" />
</td>
<td>
<asp:ImageButton ID="Pr2" runat="server" ImageUrl="~/CMSC-Images/Ic ons/printe r1.png" CommandName="Pr2" Width="20" Height="20" AlternateText="Print List" Visible="false" />
</td>
</tr>
</ItemTemplate>
</telerik:RadListView>
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="PlaceHo
<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/Ic
<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/Ic
CommandName="Pr1" Width="20" Height="20" AlternateText="Print List" />
</td>
<td>
<asp:ImageButton ID="Pr2" runat="server" ImageUrl="~/CMSC-Images/Ic
</td>
</tr>
</ItemTemplate>
</telerik:RadListView>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
Thanks
ASKER
Sorry was on a tight schedule... closing ticket
can u post your aspx page... what is the error it is throwing now??