Manage a radlistview

4 posts, 0 answers
  1. Fabio Cirillo
    Fabio Cirillo avatar
    180 posts
    Member since:
    Jan 2010

    Posted 03 Dec 2012 Link to this post

    Hi,

    i've a web page where insert a radlistview and connect to list of object...my code is:
    As you can see there is a field userid, I wish that the value of the userid is passed on the button, is this possible?

    <fieldset style="float: left; width: 340px; height: 195px">
                               <legend>Category:
                                   <%# CType(Container.DataItem, PropertyUtente).Category%>
                               </legend>
                               <table cellpadding="0" cellspacing="0" width="95%">
                                   <tr>
                                       <td style="width: 75%;">
                                           <table cellpadding="5" cellspacing="0">
                                               <tr>
                                                   <td style="width: 25%;">
                                                       Userid:
                                                   </td>
                                                   <td style="width: 75%; text-align:left">
                                                       <%# CType(Container.DataItem, PropertyUtente).Userid%>
                                                   </td>
                                               </tr>
                                               <tr>
                                                   <td style="width: 25%;">
                                                       Name:
                                                   </td>
                                                   <td style="width: 75%; text-align:left">
                                                       <%# CType(Container.DataItem, PropertyUtente).user%>
                                                   </td>
                                               </tr>
                                               <tr>
                                                   <td>
                                                       City:
                                                   </td>
                                                   <td style="width: 75%; text-align:left">
                                                       <%# CType(Container.DataItem, PropertyUtente).city%>
                                                   </td>
                                               </tr>
                                               <tr>
                                                   <td>
                                                       Phone:
                                                   </td>
                                                   <td style="width: 75%; text-align:left">
                                                       <%# CType(Container.DataItem, PropertyUtente).phone%>
                                                   </td>
                                               </tr>
                                               <tr>
                                                   <td>
                                                       Cellular:
                                                   </td>
                                                   <td style="width: 75%; text-align:left">
                                                       <%# CType(Container.DataItem, PropertyUtente).Cellular%>
                                                   </td>
                                               </tr>
                                               <tr>
                                                   <td>
                                                    </td>
                                                   <td style="width: 75%; text-align:left">
                                                       <asp:Button ID="Button1" runat="server" Text="Details"  />
                                                   </td>
                                               </tr>
                                           </table>
                                       </td>
                                        <td style="vertical-align: top; text-align: right; width: 25%;">
                                            <asp:Image ID="Image1" runat="server" ImageUrl='<%# CType(Container.DataItem, PropertyUtente).imageprofile%>' Height="120px" Width="100px"/>
                                       </td>                            
                                   </tr>
                               </table>
                           </fieldset>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Dec 2012 Link to this post

    Hi,

    I suppose you want to get the value of userid on a button click. One suggestion is that you can set it as DataKeyNames and access it as shown below.
    aspx:
    <telerik:RadListView ID="RadListView1" runat="server"  DataKeyNames="Userid">
    C#:
    protected void Button1_Click(object sender, EventArgs e)
    {
            Button button = sender as Button;
            RadListViewDataItem item = button.Parent as RadListViewDataItem;
            Response.Write(item.GetDataKeyValue("Userid"));
     }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Fabio Cirillo
    Fabio Cirillo avatar
    180 posts
    Member since:
    Jan 2010

    Posted 03 Dec 2012 Link to this post

    Hi,
    i've written with vb net code so, but when start the page and start the debug to see if the vb code is execute, i see that the code is not executed...Why? where am I wrong?

    <telerik:RadListView ID="RadListView1" runat="server"  DataKeyNames="Userid"
                        ItemPlaceholderID="Container" AllowPaging="True" PageSize="6" Skin="Simple">
                        <LayoutTemplate>
                            <fieldset id="FieldSet1">
                                <legend>Risultati della ricerca:</legend>
                                <asp:PlaceHolder ID="Container" runat="server"></asp:PlaceHolder>
                                <div style="clear: both">
                                </div>
                                <div>
                                    <div style="float: left; margin-left: 30%;">
     <asp:Button runat="server" ID="btnFirst" CommandName="Page" CommandArgument="First"
     Text="Prima" Enabled="<%#Container.CurrentPageIndex > 0 %>"></asp:Button>
     <asp:Button runat="server" ID="btnPrev" CommandName="Page" CommandArgument="Prev"
     Text="Precedente" Enabled="<%#Container.CurrentPageIndex > 0 %>"></asp:Button>
                                        <span style="vertical-align: top; position: relative; top: 4px">Page
                                            <%#Container.CurrentPageIndex + 1 %>
                                            di
                                            <%#Container.PageCount %></span>
     <asp:Button runat="server" ID="btnNext" CommandName="Page" CommandArgument="Next"
     Text="Successivca" Enabled="<%#Container.CurrentPageIndex + 1 < Container.PageCount %>">
                                        </asp:Button>
     <asp:Button runat="server" ID="btnLast" CommandName="Page" CommandArgument="Last"
     Text="Ultima" Enabled="<%#Container.CurrentPageIndex + 1 < Container.PageCount %>">
                                        </asp:Button>
                                    </div>
                                </div>
                            </fieldset>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <fieldset style="float: left; width: 325px; height: 195px">
                                <legend>Category:
                                    <%# CType(Container.DataItem, PropertyUtente).Category%>
                                </legend>
                                <table cellpadding="0" cellspacing="0" width="95%">
                                    <tr>
                                        <td style="width: 80%;">
                                            <table cellpadding="4" cellspacing="0">
                                                <tr>
                                                </tr>
                                                <tr>
                                                    <td style="width: 20%;">
                                                        Name:
                                                    </td>
                                                    <td style="width: 80%; text-align:left">
                                                        <%# CType(Container.DataItem, PropertyUtente).Name%>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 20%;">
                                                        City:
                                                    </td>
                                                    <td style="width: 80%; text-align:left">
                                                        <%# CType(Container.DataItem, PropertyUtente).City%>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 20%;">
                                                        Phone:
                                                    </td>
                                                    <td style="width: 80%; text-align:left">
                                                        <%# CType(Container.DataItem, PropertyUtente).Phone%>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width: 20%;">
                                                        Cellular:
                                                    </td>
                                                    <td style="width: 80%; text-align:left">
                                                        <%# CType(Container.DataItem, PropertyUtente).Cellular%>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                    </td>
                                                    <td style="width: 100%; text-align:center">
                                                        <telerik:RadButton ID="RadButton1" runat="server" Text="View detail" Skin="Sunset">
                                                        </telerik:RadButton>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                         <td style="vertical-align: top; text-align: right; width: 100px;">
                                             <asp:Image ID="Image1" runat="server" ImageUrl='<%# CType(Container.DataItem, PropertyUtente).imageprofile%>' Height="120px" Width="100px"/>
                                        </td>                            
                                    </tr>
                                </table>
                            </fieldset>
                        </ItemTemplate>
                    </telerik:RadListView>
    Protected Sub RadButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
        Dim button As RadButton = CType(sender, RadButton)
        Dim item As RadListViewDataItem = CType(button.Parent, RadListViewDataItem)
        Response.Write(item.GetDataKeyValue("Userid"))
    End Sub
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 03 Dec 2012 Link to this post

    Hi,

    After inspecting your code I found that you are not attaching the click event of the RadButton. Please make sure that you are attaching the click event to the RadButton and let me know if you need further assistance.

    ASPX:
    <telerik:RadButton ID="RadButton1" runat="server" Text="View detail" Skin="Sunset"  OnClick="RadButton1_Click">
    </telerik:RadButton>

    C#:
    Protected Sub RadButton1_Click(sender As Object, e As EventArgs)
        Dim button As RadButton = TryCast(sender, RadButton)
        Dim item As RadListViewDataItem = TryCast(button.Parent, RadListViewDataItem)
        Response.Write(item.GetDataKeyValue("CustomerID"))
    End Sub

    Thanks,
    Shinu.
Back to Top