Access to control in radlistview

7 posts, 1 answers
  1. Arian
    Arian avatar
    5 posts
    Member since:
    May 2011

    Posted 04 May 2011 Link to this post

    hi
    i need to access to the control in radlist view . i founde some examples in forum but none of them didn't solve my problem. or where in VB.NET and i couldn't understand.
    so please tell me how can i access to controls and theire properties in itemtemplate.

    <telerik:RadListView ID="RadListView1" runat="server" DataSourceID="SqlDataSource1"
        ItemPlaceholderID="ListViewContainer" Width="800px" Height="380px" 
    AllowCustomPaging="True" AllowCustomSorting="True" AllowNaturalSort="True" 
    AllowPaging="True" >
      
        <LayoutTemplate>
            <asp:PlaceHolder runat="server" id="ListViewContainer" />
              
        </LayoutTemplate>
          
        <ItemTemplate>
            <fieldset style="float: left; width: 350px; height: 150px;">
                <legend><b>نام فروشگاه :</b>:
                    <%#Eval("ShopName")%></legend>
                  
                         <table style="width:100%;height:100%;">
                            <tr>
                                <td><asp:Image runat="server" ID="Image1" ImageUrl='<%#Eval("imageURL") %>'
                            AutoAdjustImageControlSize="false" Width="90px" Height="110px" ToolTip='<%#Eval("ShopName") %>'
                            AlternateText='<%#Eval("ShopName") %>' />
                                </td>
                                <td>
                                <div style="width:100%;height:100%;">
                                    <label>
                                    جزئیات:</label>
                                <%#Eval("details")%>
                                   <br />
                                <asp:Button ID="post" runat="server" Text="دیدن محصولات" PostBackUrl="~/Comidity.aspx" />
                                
                               <asp:Label ID="Label1" runat="server" Text='<%#Eval("ID") %>'></asp:Label>
                                </div>
                                 
                                </td>                    
                            </tr>
                         </table>
                          
            </fieldset>
        </ItemTemplate>
    </telerik:RadListView>

    i want to access to Label1 and read it property.
    i added all script manager and ajax manager and etc.

    thank you.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 May 2011 Link to this post

    Hello Arian,

    Check out the following documentation.
    Accessing Controls in RadListView

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Arian
    Arian avatar
    5 posts
    Member since:
    May 2011

    Posted 05 May 2011 Link to this post

    hellow shinu
    thank you for your answer but i still have problem
    i'm going to tell you full story and please help me how can i handle this.
    im loading data in list view and i have to have a buttom in every record that handle postback to another page. by clickin button i have to pass the ID of the record to next page and use it in a variable. any suggestion?
  5. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 May 2011 Link to this post

    Hello Arian,

    Try to get the label value from code, store it in a session variable and then redirect to another page like below.

    ASPX:
    <asp:Button ID="post" runat="server" Text="دیدن محصولات"  CommandName="post" />

    C#:
    protected void RadListView1_ItemCommand(object sender, RadListViewCommandEventArgs e)
        {
           if (e.CommandName == "post")
            {
                RadListViewDataItem item = (RadListViewDataItem)e.ListViewItem;
                Label label = item.FindControl("Label1") as Label;
                Session["value"] = label.Text;
                Response.Redirect("url");
            }
        }

    -Shinu.
  6. Arian
    Arian avatar
    5 posts
    Member since:
    May 2011

    Posted 06 May 2011 Link to this post

    Thank you  shinu.
  7. rahul
    rahul avatar
    27 posts
    Member since:
    Mar 2014

    Posted 10 Apr 2014 in reply to Shinu Link to this post

    Hi Shinu,

    How can access asp control in radlistview client side using JavaScript or j query.

    Thanks,
    Rahul
  8. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Apr 2014 in reply to rahul Link to this post

    Hi Rahul,

    Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadListView ID="RadListView1" Width="97%" runat="server" DataSourceID="SqlDataSource1"
        ItemPlaceholderID="ProductsHolder">
        <LayoutTemplate>
            <fieldset style="max-width: 920px;" id="FieldSet1">
                <legend>Products</legend>
                <asp:Panel ID="ProductsHolder" runat="server" />
            </fieldset>
        </LayoutTemplate>
        <ItemTemplate>
            <asp:Label ID="Lable1" runat="server" Text="Label1" CssClass="lbl1">
            </asp:Label>
        </ItemTemplate>
    </telerik:RadListView>

    JavaScript:
    function pageLoad() {
        var label = document.getElementsByClassName("lbl1");
        //all the controls with the class name lbl1
        //here you will get all the labels
    }

    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017