Get img tag id value from CMSRepeater

Rajendrasinh Jadeja asked on November 25, 2017 05:12

Hi, I have a webpart that contain a CMSRepeater control:

<cms:CMSRepeater ID="CMSRepeater1" runat="server>
             <li><span><%# Container.ItemIndex + 1 %></span><img id="<%#Eval("EventTemplateID")%>"  
             class="droppable" src="~/CMSPages/GetFile.aspx?guid=<%#                 CMS.Controls.CMSAbstractTransformation.Methods.IfCompare(Eval("TemplateThumbnail"),"00000000-
             0000-0000-0000-000000000000",Eval("TemplateThumbnail"),Eval("TemplateImage")) %>" width="160" height="150" /></li>

In the code behind:

string customTableClassName = "customtable.InvitationBanner";
DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);               

foreach (var itemEquipment in CMSRepeater1.Items)
    //here i want to get img tag id value which is in eval value        

how can i get img tag id value from eval template id in code behind

Thanks and Regards, Rajendrasinh Jadeja

Recent Answers

Brenden Kehren answered on November 27, 2017 14:46

A few things:

  • if you're using a repeater, don't use the <ItemTemplate>, use transformations then the webpart isn't hard coded.
  • if you're doing something as simple as what you're showing above, then I'd suggest using a custom table repeater webpart.
  • if you need to write code for a transformation, look into writing a custom transformation method vs. a whole new webpart.
  • if you must create a custom webpart, use the API to loop through your data, don't loop through the data in the repeater.

    var tableItems = CMS.CustomTables.CustomTableItemProvider.GetItems("customtable.InvitationBanner").Where("Column1 = 'something'").OrderBy("Column1");
    CMSRepeater1.DataSource = tableItems;

    foreach (CMS.CustomTables.CustomTableItem cti in tableItems)
    string templateImage = cti.GetValue("TemplateImage", "");

0 votesVote for this answer Mark as a Correct answer

Rajendrasinh Jadeja answered on November 30, 2017 05:24

Hi Brenden Kehren,

Thank you for your response i will try it.

Thanks and Regards, Rajendrasinh Jadeja

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.