Selecting an item from ListView

2 posts, 0 answers
  1. Kamal Mostofi
    Kamal Mostofi avatar
    56 posts
    Member since:
    Jan 2010

    Posted 11 May 2010 Link to this post

    Hi,
    I have the following code in my asp page. I would like to click on Select button and get the logoid which is in a hidden field. but it won't work when i click on the button.
                 <telerik:RadListView ID="dvlogo1" runat="server" DataSourceID="dslogo"
                ItemPlaceholderID="PlaceHolder1" AllowPaging="true" OnItemCommand="dvlogo1_ItemCommand" >
                <LayoutTemplate>
                    <div class="sushibar">
                        <asp:Panel ID="SushiPanel" runat="server">
                            <div class="sushi">
                                <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
                            </div>
                            <telerik:RadDataPager ID="RadDataPager1" runat="server" PageSize="10" Skin="Black">
                                <Fields>
                                    <telerik:RadDataPagerButtonField FieldType="Numeric" />
                                </Fields>
                            </telerik:RadDataPager>
                        </asp:Panel>
                    </div>
                </LayoutTemplate>
                <ItemTemplate>
                    <div class="category">
                        <p><asp:HiddenField runat="server" ID="hidlogoid" Value='<%# Eval("logoid") %>' />
                                                    
                            <%#Eval("Title") %>
                        </p>
                        <asp:Image runat="server" ID="imglogo2" Height="70px" Width="70px" ImageUrl='<%# Eval("logopath") %>' />
                         <p>
                            <asp:Button runat="server" ID="cmdselectlogo2" Text="Select" Font-Size="10px" CommandName="select" CommandArgument='<%# Eval("logopath") %>' />
                         </p>

                    </div>
                </ItemTemplate>
                <SelectedItemTemplate>
                    <div class="selected">
                        <p><asp:HiddenField runat="server" ID="hidlogoid1" Value='<%# Eval("logoid") %>' />
                                                    
                            <%#Eval("Title") %>
                        </p>
                         <asp:Image runat="server" ID="imglogo2" Height="70px" Width="70px" ImageUrl='<%# Eval("logopath") %>' />
                         <p>
                            <asp:Button runat="server" ID="cmdselectlogo2" Text="Select" Font-Size="10px" CommandName="select" CommandArgument='<%# Eval("logopath") %>' />
                         </p>
                    </div>
                </SelectedItemTemplate>
            </telerik:RadListView>

    C# Code
             protected void dvlogo1_ItemCommand(object source, RadListViewCommandEventArgs e)
            {
                if (e.CommandName == RadListView.SelectCommandName)
                {
                    RadListViewDataItem item = e.ListViewItem as RadListViewDataItem;
                    string myValue = item.GetDataKeyValue("logoid").ToString();
                }
                //switch (e.CommandName)
                //{
                //    case "selectlogo":
                //        Session["logo"] = e.CommandArgument;
                //       // hid = (this.dvlogo1.FindControl("hidlogoid") as HiddenField).Value;
                //        Session["logoid"] = (this.dvlogo1.FindControl("hidlogoid") as HiddenField).Value;

                //        break;
                //}
            }

    I appreciate your help very much.

    thanks,
    kamal



  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 13 May 2010 Link to this post

    Hello Kamal,

    You should use the current item as a search container instead the entire RadListView instance.

    if (e.CommandName == RadListView.SelectCommandName)
    {            
        Session["logoid"] = (e.ListViewItem.FindControl("hidlogoid") as HiddenField).Value;
    }

    Best wishes,
    Rosen
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top