This is a migrated thread and some comments may be shown as answers.

Access to control in radlistview

6 Answers 241 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Arian
Top achievements
Rank 1
Arian asked on 05 May 2011, 02:56 AM
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.

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 May 2011, 12:56 PM
Hello Arian,

Check out the following documentation.
Accessing Controls in RadListView

Thanks,
Shinu.
0
Arian
Top achievements
Rank 1
answered on 05 May 2011, 09:24 PM
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?
0
Accepted
Shinu
Top achievements
Rank 2
answered on 06 May 2011, 06:05 AM
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.
0
Arian
Top achievements
Rank 1
answered on 06 May 2011, 05:13 PM
Thank you  shinu.
0
rahul
Top achievements
Rank 1
answered on 10 Apr 2014, 11:34 AM
Hi Shinu,

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

Thanks,
Rahul
0
Shinu
Top achievements
Rank 2
answered on 14 Apr 2014, 04:55 AM
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.
Tags
ListView
Asked by
Arian
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Arian
Top achievements
Rank 1
rahul
Top achievements
Rank 1
Share this question
or