Click here to Skip to main content
15,891,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a RadTextBox in a ListView ItemTemplate and I am wanting to adjust he number of rows depending on the length of the data. I tried to reference the RadTextBox in the ListView ItemBound event, but I am getting error: "txtReviewercomments" is not declared. It may be inaccessible due to its protection level.

Here is be ASPX

ASP.NET
<pre>                        <asp:ListView ID="ListViewAssessmentComment" runat="server" DataKeyNames="ID" Visible="false"
                            DataSourceID="AssessmentCommentsData" InsertItemPosition="LastItem">
                            <ItemTemplate>
                                <tr style="background-color: #FFFFFF; color: #000000;">
                                    <td rowspan="2">
                                        <asp:ImageButton ID="ImageButtonEdit" runat="server" ImageUrl="~/Images/Edit.gif"
                                            CommandName="Edit" />
                                        <br />
                                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("PMID") %>' Visible="false"
                                            Font-Size="XX-Small" />
                                    </td>
                                    <td rowspan="2">
                                        <telerik:RadTextBox ID="ReviewCommentsLabel" runat="server" TextMode="MultiLine"
                                            Resize="Vertical" BackColor="White" Width="750px" ForeColor="Black" ReadOnly="true"
                                            Font-Size="Small" Text='<%# Eval("ReviewComments") %>'>
                                        </telerik:RadTextBox>
                                    </td>
</pre>



Here is my VB.NET code

VB
<pre>    Private Sub ListViewAssessmentComment_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles ListViewAssessmentComment.ItemDataBound


        If e.Item.ItemType = ListViewItemType.DataItem Then
            Dim txtReviewercomments = DirectCast(e.Item.FindControl("ReviewCommentsLabel"), RadTextBox)
        End If

        If Not IsNothing(txtReviewercomments) Then
            If Len(txtReviewercomments) > 80 Then
                txtReviewercomments.Rows = ((Len(txtReviewercomments.Text) * 10) / 750) + 1
            Else
                txtReviewercomments.Rows = 1
            End If
        End If
    End Sub
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900