将RadGrid中的Control设置为Visible-False

时间:2014-06-20 19:18:12

标签: html asp.net vb.net telerik

我需要帮助在RadGrid中获取Control的ID才能将其设置为Visable = False。

最后一个功能实际上是根据来自数据库的值创建一个pic。如何在我添加到Visible false的Pic旁边设置HyperLink?

我认为我需要发送函数RenderLinked的超链接控件,但我不知道如何,我希望有人可以告诉我。

<telerik:RadGrid
    ID="rgPhoneBook"
    runat="server"              
    AutoGenerateColumns="False"
    AllowPaging="True"
    AllowSorting="True"
    PageSize="50" 
    CellSpacing="0" GridLines="None" 
    OnItemCommand="rgPhoneBook_ItemCommand"
    OnPageIndexChanged="rgPhoneBook_OnPageIndexChanged"
    OnSortCommand="rgPhoneBook_OnSortCommand"
    OnItemCreated="rgPhoneBook_OnItemCreated"
    EnableHeaderContextFilterMenu="True"
    Width="933px" 
    Height="528px">
    <ClientSettings>
        <Selecting AllowRowSelect="True"></Selecting>
        <Scrolling AllowScroll="true" UseStaticHeaders="True" SaveScrollPosition="true" FrozenColumnsCount="2" />              
    </ClientSettings>  
    <MasterTableView ShowHeadersWhenNoRecords="true" NoMasterRecordsText="No PhoneBook Records to display" Font-Size="11px" GridLines="None" AllowPaging="True" ItemStyle-Height="25px" CommandItemDisplay="Top" AllowAutomaticUpdates="False" TableLayout="Auto" DataKeyNames="LocationID,PersonID" ClientDataKeyNames="LocationID,PersonID">
        <PagerStyle Mode="NumericPages"></PagerStyle>
        <Columns>
            <telerik:GridTemplateColumn HeaderText="Linked"  HeaderStyle-Width="45px" >
                <ItemTemplate>
                    <span id="spanHyperLink" style="visibility:visible" runat="server">
                        <asp:HyperLink ID="Link" runat="server" Text="Link">
                        </asp:HyperLink>
                    </span>
                    <%# RenderLinked(DataBinder.Eval(Container.DataItem, "Linked"))%> 
                </ItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>


Protected Function RenderLinked(ByVal inputVal As String) As String
    Dim output As String = ""
    Try
        Dim svcs As New SystemServices
        If Not inputVal Is Nothing And Not String.IsNullOrEmpty(inputVal) Then
            If inputVal = True Then
                output = "<img src='" + Globals.gRootRelativeSecureURL("\Images\Layout\Link.png") + "' width=""13"" height=""13"" border=""0"" align=""absmiddle"">"
            Else
                'Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
                'Dim link As HyperLink = DirectCast(item("Link").Controls(0), HyperLink)
                'LinkButton.DisabledCssClass = True
                Me.Page.ClientScript.RegisterStartupScript(Me.GetType(), "StartupScript", "Sys.Application.add_load(function() { DisableHyperLinkCSS();  });", True)

                'output = "<a herf='#' onclick='showPersonLinkModal() ;'>Link</a>"
            End If
        End If
    Catch ex As Exception
        Globals.SendEmailError(ex, m_User.SessionID, System.Reflection.MethodBase.GetCurrentMethod.Name.ToString(), Request.RawUrl.ToString(), m_User.UserID)
    End Try
Return output
End Function

1 个答案:

答案 0 :(得分:0)

如果要在代码中将行绑定到数据1后面的代码中设置一些控件的属性visible=false,则可以使用RowDataBound事件并在其中编写以下代码&#39; s处理程序

Control_Type Control_ID = (Control_Type) e.Row.FindControl("Control_ID");
Control_ID.Visible = false;

如果你想在javascript中设置它,

rgPhoneBook.Rows[Record_Index].Cells[0].Visible = false;

希望这会对你有所帮助。上面的代码在C#中,请将其转换为VB中的等效代码。