OnSelectedIndexChanged fail

4 posts, 0 answers
  1. Pierre
    Pierre avatar
    212 posts
    Member since:
    Apr 2007

    Posted 10 Nov 2009 Link to this post

    I try to fire the server side function when click on the image of the image librairy:

                                    <telerik:RadListView runat="server" ID="RadLVPhotos" Enabled="false" Visible="true" 
                                        AllowPaging="true" PageSize="10" DataKeyNames="Id" 
                                         OnNeedDataSource="RadLVPhotos_NeedDataSource" OnSelectedIndexChanged="RadLVPhotos_SelectedIndexChanged" ItemPlaceholderID="ProductsHolder">  
                                        <LayoutTemplate> 
                                            <div id="list">  
                                                <div style="clear: both;">  
                                                </div> 
                                                <fieldset runat="server" id="ProductsHolder" /> 
                                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
                                                <div style="clear: both;">  
                                                </div> 
                                            </div> 
                                        </LayoutTemplate> 
                                        <EmptyDataTemplate> 
                                            <legend>Photos</legend>Aucune photo...  
                                        </EmptyDataTemplate> 
                                        <ItemTemplate> 
                                            <fieldset style="float: left; margin: 5px 5px 5px 5px; padding: 2px 2px 2px 2px;  
                                                background: #eeeeee" class="myClass" onmouseover="containerMouseover(this)" onmouseout="containerMouseout(this)">  
                                                <telerik:RadBinaryImage Style="cursor: pointer;" runat="server" ID="RadBinaryImage1" 
                                                    DataValue='<%#Eval("Fichier.Content") %>' AlternateText='<%#Eval("Fichier.itemID") %>' Height="120px" Width="120px" 
                                                    ResizeMode="Fit" onclick="" /> 
                                                <br /> 
                                                <div style="margin-top: -30px; position: fixed; display: none; width: 60px;">  
                                                </div> 
                                            </fieldset> 
                                        </ItemTemplate> 
                                    </telerik:RadListView> 

        Protected Sub RadLVPhotos_SelectedIndexChanged(ByVal sender As ObjectByVal e As EventArgs)  
            Dim radLVPhotos As RadListView = DirectCast(sender, RadListView)  
     
            If radLVPhotos.SelectedItems.Count <> 0 Then 
     
            Else 
                radLVPhotos.ClearSelectedItems()  
            End If 
        End Sub 

    Nothing append...

    any suggestion?
  2. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 11 Nov 2009 Link to this post

    Hello Pierre,

    To achieve your goal you can wrap the RadBinaryImage instance inside asp LinkButton with CommandName="Select" and empty Text value. See how this is done for the second RadListView on the 'First look' demo of the product:

    http://demos.telerik.com/aspnet-ajax/listview/examples/firstlook/defaultcs.aspx

    Best regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pierre
    Pierre avatar
    212 posts
    Member since:
    Apr 2007

    Posted 11 Nov 2009 Link to this post

    Thanks that work now. But what about extracting date from the selected item?
    I try this:
    I need to get the ID of the selected item in the cmdRemoveIng_Click function:
        Protected Sub RadLVPhotos_SelectedIndexChanged(ByVal sender As ObjectByVal e As EventArgs)  
            Dim radLVPhotos As RadListView = DirectCast(sender, RadListView)  
            Dim cmdRemoveImg As Button = DirectCast(RadPanelBar1.FindItemByValue("Photos").FindControl("cmdRemoveImg"), Button)  
     
            If radLVPhotos.SelectedItems.Count <> 0 Then 
                cmdRemoveImg.Enabled = True 
            Else 
                radLVPhotos.ClearSelectedItems()  
                cmdRemoveImg.Enabled = False 
            End If 
        End Sub 
     
        Protected Sub cmdRemoveImg_Click(ByVal sender As ObjectByVal e As EventArgs)  
            Dim radLVPhotos As RadListView = DirectCast(RadPanelBar1.FindItemByValue("Photos").FindControl("radLVPhotos"), RadListView)  
     
            If radLVPhotos.SelectedItems.Count <> 0 Then 
                Dim values As New Hashtable()  
                radLVPhotos.SelectedItems(0).ExtractValues(values)  
                Dim nID As Int32 = values("ID")  
                Dim scope As IObjectScope = ScopeFactory.GetPerRequestScope(HttpContext.Current)  
                Dim oProdFich As ProduitsFichier = scope.Extent(Of ProduitsFichier)().Single(Function(p As ProduitsFichier) p.Id = nID)  
                scope.Transaction.Begin()  
                scope.Remove(oProdFich)  
                scope.Transaction.Commit()  
                radLVPhotos.Rebind()  
            End If 
        End Sub 

    The ExtractValues return nothing. But the SelectedItems.count = 1.
    Any suggestion?
  5. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 12 Nov 2009 Link to this post

    Hello Pierre,

    Do you use binding expressions for the controls (and ID field in particular) inside the ItemTemplate/SelectedItemTemplate of RadListView as illustrated on this online demo of the product? Thus you should be able to fetch the data as expected.

    You may also provide the entire markup and code-behind implementation related to RadListView in this thread - thus I will be able to familiarize with your complete code logic and advice you further.

    Best regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top