We help IT Professionals succeed at work.

hide link button and disable

993 Views
Last Modified: 2012-08-14
I am using a telerik grid so that I can use detail tables.  What i am having trouble with is getting the value of a cell and depending on that value disabling the link button on the same row.  So currently whent he grid loads nothing is changed even though a couple link buttons should be hidden, but when I click on one and it posts back all the link butons disapear.  What am I doing wrong here and why does it not work on grid load.

 Protected Sub myIssueGrid_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles myIssueGrid.ItemDataBound
        If e.Item.OwnerTableView.Name = "myIssueGrid" Then
            If TypeOf e.Item Is GridDataItem Then
                Dim Item As GridDataItem = DirectCast(e.Item, GridDataItem)
                Dim lbl As TableCell = Item("strTransaction")
                Dim Trans As LinkButton = DirectCast(Item.FindControl("lnkTransfer"), LinkButton)
                Dim tType As Label = DirectCast(Item.FindControl("lbltranstype"), Label)
                Dim image As Image = DirectCast(Item.FindControl("imgReturn"), Image)
                Dim type As Integer

                Type = Convert.ToInt32(tType.Text)

                If type = 6 Or tType.Text = "TRANSFER" Then   Either one of these should work
                    Trans.Enabled = False
                    image.Visible = False
                End If
            End If
        End If
    End Sub
Comment
Watch Question

HainKurtSr. System Analyst
CERTIFIED EXPERT

Commented:
" link butons disapear" but in the code it says disable it, not hide it...

or I could not get the issue...

Author

Commented:
Hi,

I am just trying to get it to do something.  Right not it does nto even disable itself.  I can still click on it and it still shows my popup that comes up, so its not even getting disabled.
HainKurtSr. System Analyst
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
hi,
I have tried both, it seemd to not even get into the main grid.  Something interesting though is I put the same code to the detailsTable grid that is a sub grid and the code works just fine.  It is really wierd, I made sure all my names where right and looked at case sensitivity becuase sometimes telerik controls can be case sensitive.

  If e.Item.OwnerTableView.Name = "myReIssueGrid" Then
            If TypeOf e.Item Is Telerik.Web.UI.GridDataItem Then
                Dim item As Telerik.Web.UI.GridDataItem = DirectCast(e.Item, Telerik.Web.UI.GridDataItem)
                Dim cancel As LinkButton = DirectCast(item.FindControl("lnkCancel"), LinkButton)
                Dim Accept As LinkButton = DirectCast(item.FindControl("lnkAccept"), LinkButton)
                Dim lbl As TableCell = item("strTransaction")
                Dim Trans As Label = DirectCast(item.FindControl("lbltrans"), Label)
                Dim TransTo As Integer

                TransTo = Convert.ToInt32(Trans.Text)

                If lbl.Text = "TRANSFER" Then
                    If TransTo = Convert.ToInt32(HFPersId.Value) Then
                        Accept.Enabled = False
                        Accept.Text = Nothing
                    End If
                End If
            End If
        End If

 <telerik:RadGrid ID="myIssueGrid" runat="server" Width="95%" BorderWidth="1px" CellPadding="6" GridLines="None" BorderColor="#404040" Skin="Web20">
                                    <MasterTableView AutoGenerateColumns="false" DataKeyNames="intIssuedID" HierarchyDefaultExpanded="false" HierarchyLoadMode="ServerBind" 
                                        BorderColor="#404040" Font-Size="12" Font-Names="Veranda,arial,sans-serif" HeaderStyle-HorizontalAlign="Center" 
                                        GridLines="Both" BorderWidth="1px" ExpandCollapseColumn-ButtonType="ImageButton" ExpandCollapseColumn-CollapseImageUrl="~/Images/30.png" 
                                        ExpandCollapseColumn-ExpandImageUrl="~/Images/29.png"><ItemStyle HorizontalAlign="Center" />
                                        <AlternatingItemStyle BackColor="#B0C4DE"  HorizontalAlign="Center" />
                                        <HeaderStyle ForeColor="White" Font-Bold="true" BorderColor="#404040" BorderWidth="1px" />
                                        <DetailTables>
                                            <telerik:GridTableView Name="myReIssueGrid" runat="server" DataKeyNames="intReIssueId, intTransTypeId" TableLayout="Fixed" BorderWidth="1px" CellPadding="6" Font-Size="10"
                                                AutoGenerateColumns="False" HeaderStyle-HorizontalAlign="Center" BorderColor="#404040" Font-Names="Veranda,arial,sans-serif" GridLines="Both" ExpandCollapseColumn-ButtonType="ImageButton"
                                                ExpandCollapseColumn-CollapseImageUrl="~/Images/30.png" ExpandCollapseColumn-ExpandImageUrl="~/Images/29.png">
                                                <ParentTableRelation>
                                                    <telerik:GridRelationFields DetailKeyField="intIssuedID" MasterKeyField="intIssuedID" />
                                                </ParentTableRelation>
                                                <HeaderStyle Font-Bold="true" HorizontalAlign="Center" CssClass="MostInnerHeaderStyle" />
                                                <ItemStyle CssClass="MostInnerItemStyle" HorizontalAlign="Center" />
                                                <AlternatingItemStyle CssClass="MostInnerAlernatingItemStyle" HorizontalAlign="Center" />
                                                <Columns>
                                                    <telerik:GridTemplateColumn HeaderText="Accept" ItemStyle-HorizontalAlign="Center">
                                                        <ItemTemplate>
                                                             <asp:LinkButton ID="lnkAccept" runat="server" CommandArgument='<%# bind("intReIssueId") %>' CommandName="Accept" Text="Accept"></asp:LinkButton>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn HeaderText="Cancel" ItemStyle-HorizontalAlign="Center">
                                                        <ItemTemplate>
                                                             <asp:LinkButton ID="lnkCancel" runat="server" CommandArgument='<%# bind("intReIssueId") %>' CommandName="Cancel" Text="Cancel"></asp:LinkButton>
                                                              <asp:Label ID="lbltrans" runat="server" Text='<%# bind("intReIssueBy") %>' Visible="false"></asp:Label>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridBoundColumn DataField="IssueBy" HeaderText="ISSUED FROM" ItemStyle-Font-Size="Smaller" />
                                                    <telerik:GridBoundColumn DataField="IssueTo" HeaderText="ISSUED TO"  ItemStyle-Font-Size="Smaller" />
                                                    <telerik:GridBoundColumn DataField="dtIssue" HeaderText="DT_ISSUED" />
                                                    <telerik:GridBoundColumn DataField="strTransaction" HeaderText="STATUS" />
                                                    <telerik:GridBoundColumn DataField="dtSign" HeaderText="DT_SIGNED" />
                                                </Columns>
                                            </telerik:GridTableView>
                                        </DetailTables>
                                         <Columns>
                                             <telerik:GridTemplateColumn HeaderText="Transfer" ItemStyle-HorizontalAlign="Center">
                                                <ItemTemplate>
                                                        <asp:LinkButton ID="lnkTransfer" runat="server" CommandArgument='<%# bind("intIssuedID") %>' CommandName="Transfer">
                                                        <asp:Image ID="imgReturn" runat="server" ImageUrl="~/Images/Transfer.png" BorderStyle="None" /></asp:LinkButton>
                                                        <asp:Label ID="lbltranstype" runat="server" Text='<%# bind("intIssuedID") %>' Visible="false"></asp:Label>
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridBoundColumn HeaderText="SN" DataField="strSN" />
                                            <telerik:GridBoundColumn HeaderText="STATUS" DataField="strTransaction" />
                                            <telerik:GridBoundColumn HeaderText="ITEM" DataField="Item" />
                                            <telerik:GridBoundColumn HeaderText="DT_ISSUED" DataField="DT_Issued" />
                                            <telerik:GridBoundColumn HeaderText="DT_SIGNED" DataField="Dt_Signed" />
                                            <telerik:GridBoundColumn HeaderText="QTY" DataField="ftQTY" />
                                        </Columns>
                                    </MasterTableView>
                                </telerik:RadGrid>

Open in new window

HainKurtSr. System Analyst
CERTIFIED EXPERT

Commented:
you should debug your code and see if it is working as intended...

put a break point on first line

>>>> BP here >>> If e.Item.OwnerTableView.Name = "myIssueGrid" Then

and see whats is wrong...

Author

Commented:
hi,

I just get a yello bar and it says return booleen but I don't see a value in there.
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Press F10 and see what next line it goes to.
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Soluiton as shown

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.