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

RadListView Id Get value

8 Answers 256 Views
ListView
This is a migrated thread and some comments may be shown as answers.
New
Top achievements
Rank 1
New asked on 29 Aug 2012, 07:19 AM

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.

8 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 Aug 2012, 07:24 AM
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.
0
New
Top achievements
Rank 1
answered on 01 Sep 2012, 06:52 AM
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.
0
Vasil
Telerik team
answered on 03 Sep 2012, 09:01 AM
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.
0
New
Top achievements
Rank 1
answered on 03 Sep 2012, 02:07 PM
Thanks For your reply Vasil

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


Thanks Advance,
Mohamed.
0
Vasil
Telerik team
answered on 03 Sep 2012, 03:10 PM
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.
0
New
Top achievements
Rank 1
answered on 04 Sep 2012, 04:32 AM
Thanks For your reply ,

See the attachment error

Thanks Advance,
Mohamed.
0
Accepted
Vasil
Telerik team
answered on 04 Sep 2012, 07:07 AM
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.
0
New
Top achievements
Rank 1
answered on 04 Sep 2012, 07:15 AM
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.
Tags
ListView
Asked by
New
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
New
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or