RadListView Id Get value

9 posts, 1 answers
  1. New
    New  avatar
    25 posts
    Member since:
    Jul 2012

    Posted 29 Aug 2012 Link to this post


    see the attachment i have bind image in radlistview ,
    after that which image i click that image how i get that id

    <telerik:RadListView ID="RadListViewAttachment" runat="server" ItemPlaceholderID="ListViewContainer"
                                            OnNeedDataSource="RadListViewAttachment_NeedDataSource" DataKeyNames="RecordID"
                                            OverrideDataSourceControlSorting="true">
                                            <LayoutTemplate>
                                                <asp:PlaceHolder runat="server" ID="ListViewContainer" />
                                            </LayoutTemplate>
                                            <ItemTemplate>
                                                <table>
                                                    <tr>
                                                        <td>
                                                            <telerik:RadBinaryImage Style="cursor: pointer; display: block;" runat="server" ID="RadBinaryImage1"
                                                                AutoAdjustImageControlSize="false" Width="15px" Height="15px" DataValue='<%#Eval("SaveFile") %>'
                                                                AlternateText="<%$ Code:Resources.Articles.Article_LargeImage %>" ToolTip="<%$ Code:Resources.Articles.Article_LargeImage %>"
                                                                onclick="<%#CreateWindowScript() %>" />
                                                        </td>
                                                        <td>
                                                            <label>
                                                                <%#Eval("OrgFileName")%></label>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </ItemTemplate>
                                        </telerik:RadListView>


    See the attachment.

    Thanks Advance,
    Mohideen.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 31 Aug 2012 Link to this post

    Hi,

    I am not quite sure about your requirement. I suppose you want to access the RadBinaryImage in ItemTemplate. Here is the sample code.
    C#:
    protected void RadListView1_ItemDataBound(object sender, RadListViewItemEventArgs e)
    {
       if (e.Item is RadListViewDataItem)
      {
          RadBinaryImage img = (RadBinaryImage)e.Item.FindControl("RadBinaryImage1");
      }
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. New
    New  avatar
    25 posts
    Member since:
    Jul 2012

    Posted 01 Sep 2012 Link to this post

    After i click that goes another form ,
    It's load on page load only after i click that button it's not come on this page ,
    It's goes on another form.

    protected string CreateWindowScript()
    {
     
        //return string.Format("var win = window.radopen('LargerImage.aspx?id={0}','Details');win.center();", attachmentrowid);
        return string.Format("ShowImage('" + attachmentrowid + "');");
    }

    function ShowImage(arg) {
                    var RadWindow = $find("<%=Details.ClientID%>");
                    RadWindow.setUrl("LargerImage.aspx?id=" + arg);
                    RadWindow.show();
                    false;
                }

    Thanks Advance,
    Mohamed.
  5. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 03 Sep 2012 Link to this post

    Hello Mohamed,

    Inside the "<%#" tag you can use the Container (that will be the current item) to pass it to the CreateWindowScript function then use it to get the dataitem ID.

    <%#CreateWindowScript(Container) %>" />

    protected string CreateWindowScript(object Container)
    {
       //......
    }

    Greetings,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. New
    New  avatar
    25 posts
    Member since:
    Jul 2012

    Posted 03 Sep 2012 Link to this post

    Thanks For your reply Vasil

    See the attachment ,
    How i get the Filed Value form the container .


    Thanks Advance,
    Mohamed.
  7. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 03 Sep 2012 Link to this post

    Hello Mohamed,

    You need to cast it to RadListViewItem in order to access the class properties.
    (Container as RadListViewItem).DataItem.FileID;
     
    //or
     
    RadListViewItem item = (RadListViewItem)Container;
    return item.DataItem.FileID;

    Don't forget to include the Telerik.Web.UI in order to cast successfully.

    Regards,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  8. New
    New  avatar
    25 posts
    Member since:
    Jul 2012

    Posted 03 Sep 2012 Link to this post

    Thanks For your reply ,

    See the attachment error

    Thanks Advance,
    Mohamed.
  9. Answer
    Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 04 Sep 2012 Link to this post

    Hello Mohamed,

    It was my mistake, try to cast to RadListViewDataItem, not RadListViewItem.

    Kind regards,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  10. New
    New  avatar
    25 posts
    Member since:
    Jul 2012

    Posted 04 Sep 2012 Link to this post

    Thanks For your Help Vasil .

    RadListViewDataItem RDListitem = (RadListViewDataItem)Container;
    //return RDListitem.DataItem.FileID;
    string Val = RDListitem.DataItem.ToString();
    string File = Val.Substring(11, 5);
    string[] FileIDArray = File.Split(',');
    string FileI = FileIDArray[0];
     
     return string.Format("ShowImage('" + FileI + "');");
    I getting Like That

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