ASP.NET Repeater DataItems - repeater

I have a simple repeater control with 5 columns and data that show up fine. But, I have a 6th data item that I need to place in the next line after each of the table rows.
I have tried it placing the 6th item in the alternating template item, and it does what I want, but, does not loop through all the rows.
From the below code, the Notes data item is the one I want to appear in a new line after each row...The code below does it, but it does not loop through:
<HeaderTemplate>
<table class="tblMoves" >
<tr>
<th>
Type
</th>
<th>
ID
</th>
<th>
First Name
</th>
<th>
Last Name
</th>
<th>
Date
</th>
</tr>
</HeaderTemplate>
<AlternatingItemTemplate>
<tr>
<td colspan="5"> <%#Eval("Notes")%></td>
</tr>
</AlternatingItemTemplate>
<ItemTemplate>
<tr>
<td><asp:Label ID="empid" Text='<%#Eval("type") %>' runat="server"></asp:Label></td>
<td><asp:Label ID="Label1" Text='<%#Eval("ID") %>' runat="server"></asp:Label></td>
<td><asp:Label ID="Label2" Text='<%#Eval("FirstName") %>' runat="server"></asp:Label></td>
<td><asp:Label ID="Label3" Text='<%#Eval("LastName") %>' runat="server"></asp:Label></td>
<td><asp:Label ID="Label4" Text='<%#Eval("Date", "{0:MM/dd/yyyy}") %>' runat="server"></asp:Label></td>
</tr>
</ItemTemplate>
<FooterTemplate> </table></FooterTemplate>
</asp:Repeater>

Just add your notes row to your item template.
<ItemTemplate>
<tr>
<td>
<asp:Label ID="empid" Text='<%#Eval("type") %>' runat="server"></asp:Label>
</td>
<td>
<asp:Label ID="Label1" Text='<%#Eval("ID") %>' runat="server"></asp:Label>
</td>
<td>
<asp:Label ID="Label2" Text='<%#Eval("FirstName") %>' runat="server"></asp:Label>
</td>
<td>
<asp:Label ID="Label3" Text='<%#Eval("LastName") %>' runat="server"></asp:Label>
</td>
<td>
<asp:Label ID="Label4" Text='<%#Eval("Date", "{0:MM/dd/yyyy}") %>' runat="server"></asp:Label>
</td>
</tr>
<tr>
<td colspan="5"><%#Eval("Notes")%></td>
</tr>
</ItemTemplate>

Related

Get verification code from a html string code using regex

I am currently writing an automation script, Where I read email Gmail through API and i am getting below html content. Now i need only code 191418 from this html content, I want to take it using regex. I tried with this
.*([0-9]{6})
To find 6 digit code but its returns 10 matchings, I am not good at regex, Can someone please help me to get the code using regex?
<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr"><br></div><u></u>
<div>
<center id="m_-2051398760120817894wrapper">
<table id="m_-2051398760120817894main" width="100%">
<tbody><tr id="m_-2051398760120817894logo">
<td>
<table width="100%">
<tbody><tr>
<td>
<img src="test.com/logo.png" width="140px" alt="xxxxx Logo" style="padding:0 10px">
</td>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td height="18px"></td>
</tr>
<tr id="m_-2051398760120817894header">
<td>
<table width="100%">
<tbody><tr>
<td height="64px" style="background-color:#10069f;color:#fff;padding-left:24px;font-weight:700">Reset your password</td>
</tr>
</tbody></table>
</td>
</tr>
<tr id="m_-2051398760120817894content">
<td>
<table width="100%">
<tbody><tr>
<td style="background-color:#f6f5ff;padding:24px 24px 16px 24px">
<p style="margin-top:0">The following is the verification code required to complete your password reset.</p>
<p style="margin-bottom:24px">Enter the following verification code on the screen during the registration, and proceed to the next step.</p>
<div style="display:block;text-align:center;margin-bottom:8px;background-color:#fff;height:92px;font-weight:600;font-size:36px;line-height:92px">191418</div>
<span style="display:block;font-size:12px;color:#5d5d5d">*The verification code is valid only for 24 hours.</span>
</td>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td height="24px"></td>
</tr>
<tr id="m_-2051398760120817894footer">
<td>
<table width="100%">
<tbody><tr>
<td style="background-color:#6d7777;padding:16px 24px;font-size:12px;color:#fff">
<table width="100%">
<tbody><tr>
<td id="m_-2051398760120817894footer-left">
<span style="display:block">amnimo Inc.</span>
<span style="display:block">0-3-30 usaa-fso, xxxxxxxx-shi, Tokyo, 180-8750, Japan</span>
<span style="display:block">Phone: +81-422-52-6779</span>
<span id="m_-2051398760120817894copyright-mb" style="margin-top:16px">© 2020 <div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr"><br></div><u></u>
<div>
<center id="m_-2051398760120817894wrapper">
<table id="m_-2051398760120817894main" width="100%">
<tbody><tr id="m_-2051398760120817894logo">
<td>
<table width="100%">
<tbody><tr>
<td>
<img src="https://test.com/logo.png" width="140px" alt="Amnimo Logo" style="padding:0 10px">
</td>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td height="18px"></td>
</tr>
<tr id="m_-2051398760120817894header">
<td>
<table width="100%">
<tbody><tr>
<td height="64px" style="background-color:#10069f;color:#fff;padding-left:24px;font-weight:700">Reset your password</td>
</tr>
</tbody></table>
</td>
</tr>
<tr id="m_-2051398760120817894content">
<td>
<table width="100%">
<tbody><tr>
<td style="background-color:#f6f5ff;padding:24px 24px 16px 24px">
<p style="margin-top:0">The following is the verification code required to complete your password reset.</p>
<p style="margin-bottom:24px">Enter the following verification code on the screen during the registration, and proceed to the next step.</p>
<div style="display:block;text-align:center;margin-bottom:8px;background-color:#fff;height:92px;font-weight:600;font-size:36px;line-height:92px">191418</div>
<span style="display:block;font-size:12px;color:#5d5d5d">*The verification code is valid only for 24 hours.</span>
</td>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td height="24px"></td>
</tr>
<tr id="m_-2051398760120817894footer">
<td>
<table width="100%">
<tbody><tr>
<td style="background-color:#6d7777;padding:16px 24px;font-size:12px;color:#fff">
<table width="100%">
<tbody><tr>
<td id="m_-2051398760120817894footer-left">
<span style="display:block">test Inc.</span>
<span style="display:block">2-9-32 ssdsa-sss, puakano-shi, Tokyo, 000-8000, Japan</span>
<span style="display:block">Phone: +81-000-00-652</span>
<span id="m_-2051398760120817894copyright-mb" style="margin-top:16px">© 2020 amnimo Inc.</span>
</td>
<td id="m_-2051398760120817894footer-right">
<span style="display:block">© 2020 amnimo Inc.</span>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</center>
</div>
</div></div> Inc.</span>
</td>
<td id="m_-2051398760120817894footer-right">
<span style="display:block">© 2020 test Inc.</span>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</center>
</div>
</div></div>
You should use some DOM library that will let you query the element you want and get its content. Parsing HTML with regex is bad idea.
If you must do it, getting six numbers is not enough - after inspecting, I see that it's div content. So I would write something among the lines:
<div[^>]*>\d{6}<\/div>
Pattern explanation:
<div - match <div literally
[^>]* - match zero or more characters other from >
> - match > literally
\d{6} - match 6 digits
<\/div> - match <\/div> literally
Regex demo
EDIT
In order to extract desired text, use capturing groups:
<div[^>]*>(\d{6})<\/div>
Then text in first capturing group will be your desired result.
Maybe try word boundaries, which will prevent matching inside longer numbers:
\b([0-9]{6})\b
https://regex101.com/r/dQAiHU/1/

How to display product variant in report?

I have create a custom module for sale order report . In my case, articles have attributes that have more then one value for example color: red, blue. I want to display in the article description the value of the variants. I tried several code but I did not get the right result either it displays all the value of an attribute.Any idea for help please?
report_saleorder.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data> ...
<table class="table table-condensed" style="margin-top:25px;">
<thead>
<tr>
<th>N°</th>
<th>REFERENCE</th>
<th>DESCRIPTION</th>
<th class="text-left">QTE</th>
<th class="text-left">PRIX UHT</th>
<th t-if="display_discount" class="text-left"
groups="sale.group_discount_per_so_line">
REMISE (%)
</th>
<th>TOTAL NET HT</th>
<th class="text-left">TVA</th>
</tr>
</thead>
<tbody class="sale_tbody">
<t t-foreach="doc.order_line" t-as="l">
<tr t-if="l.product_uom_qty">
<td>
<span t-esc="str(l_index+1)"/>
</td>
<td>
<span t-field="l.product_id.default_code"/>
</td>
<span t-field="value.name"/>
<td style="width:50%;">
[<span t-field="l.product_id.name"/>]
<br/>
<t t-foreach="l.product_id.attribute_line_ids" t-as="variant">
<!-- - -->
<strong><span t-field="variant.attribute_id"/>:
</strong>
<t t-foreach="variant.value_ids" t-as="value">
<!--<span t-field="variant.value_ids.name"/>-->
<span t-field="value.name"/>
<!--<br/>-->
</t>
</t>
<span t-field="l.product_id.description_sale"/>
<td class="text-left" style="width:7%;">
<span t-esc="'%.f'%(l.product_uom_qty)"/>
<!--<span groups="product.group_uom" t-field="l.product_uom"/>-->
</td>
<td class="text-left" style="width:12%;">
<span t-field="l.price_unit"/>
</td>
<td t-if="display_discount" class="text-left"
groups="sale.group_discount_per_so_line" style="width:11%;">
<span t-esc="'%.f'%(l.discount)"/>
</td>
<td style="width:15%;">
<span t-field="l.price_subtotal"/>
</td>
<td class="text-left" style="width:9%">
<span t-esc="', '.join(map(lambda x: (x.description or x.name), l.tax_id))"/>
</td>
</tr>
</t>
</tbody>
</table>
This question is similar and somehow a duplicate of:
(odoo10) how to add product attributes in pdf invoice
See how to do it there

Code after CFInclude seems to disappear or is not rendered

Having some issues with a ColdFusion application here. I'm trying to add in a <cfinclude template="header.cfm"/> and it renders correctly however the rest of the cf code seems to disappear, not sure if its not being rendered or just not showing up because of the cfinclude statement running. This is for a page header I'm trying to insert.
Is there a way to insert the cfincludes and have it stop so the rest of the page can process? Does my question make sense?
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<!-- fwtable fwsrc="header.png" fwbase="default.gif" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="1" -->
<tr>
<td><img name="grantpro" src="images/grantpro.gif" width="411" height="80" border="0" alt=""></td>
<td><img name="gpimage" src="images/gpimage.jpg" width="189" height="80" border="0" alt=""></td>
</tr>
<tr>
<td colspan="2" align="center">
<table width="599px" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td colspan="4"><div align="center"><font size="5"><strong>FDC Menu</strong></font></div></td>
</tr>
<td colspan="3"><strong>FDC Pending Proposals:</strong></td>
</tr>
<tr>
<td> </td>
<td colspan="2">By Applicant Name</td>
</tr>
<tr>
<td> </td>
<td colspan="2">By Grant Type</td>
</tr>
<tr>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="3"><strong>FDC Funded Proposals:</strong></td>
</tr>
<tr>
<td> </td>
<td colspan="2"><strong><em>Current Year</em></strong></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>By Applicant Name</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>By Grant Type</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><em><strong>Prior Years</strong></em></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>By Applicant Name </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>By Grant Type</td>
<cfinclude template="cssmenu/header.cfm"/>
</table>
<p align="center"><strong>Logout</strong></p> </td>
The following code shows where the problem is
<tr>
<td> </td>
<td> </td>
<td>By Grant Type</td>
<cfinclude template="cssmenu/header.cfm"/>
</table>
Solution 1:
This is the recommended solution
The <cfinclude> probably should be moved outside of the </table>
Solution 2:
cssmenu/header.cfm would need to finish the current table row and start an new one. This is not recommended. It is not modular at all.
</tr>
<tr>
<td colspan="3">
... Content goes here ...
</td>
</tr>
You are missing a </tr> before the <cfinclude>. Also it seems like an odd place to include a header, rather add another table row and td and include the header inside of the <td> not in between the table code as this is causing it to break.

Grails gsp template. Pass params from gsp and accept their on template

<g:each var="dep" in="${depList}">
<tr>
<td>
${dep.depName}
</td>
<td>
${dep.location}
</td>
<td>
<g:render template="listTemplate" model="${dep.clients}"/>
</td>
<td>
<g:checkBox name="departments" value="${dep.id}" checked="false" />
</td>
</tr>
</g:each>
From gsp page I need send model(params) depList on the template where I'm accept their/ How can I do this?
very close:
<g:render template="listTemplate" model="[clients:dep.clients]"/>
You can use like this.
<g:each var="dep" in="${depList}">
<tr>
<td>
${dep.depName}
</td>
<td>
${dep.location}
</td>
<td>
<g:render template="listTemplate" model="[clientlist: dep.clients]"/>
</td>
<td>
<g:checkBox name="departments" value="${dep.id}" checked="false" />
</td>
</tr>
</g:each>

Linux (sed|PCRE|grep) Regular expression to isoloate XML (KML) style data conditionally

Updates after sample code.
Solution: as provided by BeniBela He figured out what I failed to make clear...It has to be command line, not necessarily regex, and offered up this solution:
xpath -e '//Placemark[contains(description, "Iron")]'
as promised:
|
( )
/ \
_______
| _ |
| | | | All must enter and pay homage! (Shrine of BeniBela)
Problem: I need some form of command line regex to accomplish the following: Detect in one file of a set of Placemarks, Placemarks which include a keyword (in this case Iron) in a contained CDATA tag. without grabbing Placemarks which do not have the keywod. (All data from <Placemark> to </Placemark> needs to be captured.)
Explanation:
Two code samples are given below, one showing three full placemarks, two of which are useless to me, the third of which I want. The second code sample shows just the one I am interested in.
I need to extract the valid Placemark from the data file (which contains hundreds of placemarks) and append it into another file. I will then merge this file into a properly formatted KML later. The data sets are from the US Geological Survey and are very large.
The idea here is to recover placemarks for mines which are extracting a given kind of Ore (Iron for this example), and create a specialized KML (Keyhole Markup Language) file for display in a Google Earth type application.
sample1 (Multiple data with one valid entry):
<Placemark>
<name>
Las Antos Prospect</name>
<Snippet>
Record 10005251</Snippet>
<description>
<![CDATA[<p>
Record <a href="http://mrdata.usgs.gov/mrds/show.php?labno=10005251">
10005251</a>
of the <a href="http://mrdata.usgs.gov/mrds/">
Mineral Resources Data System</a>
</p>
<table border='1' padding='3' cellspacing='0'>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
oper_type</th>
<td>
Unknown</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
dev_stat</th>
<td>
Occurrence</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
ore</th>
<td>
Limestone</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
model</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod1</th>
<td>
Limestone, General</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod2</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod3</th>
<td>
</td>
</tr>
</table>
]]>
</description>
<styleUrl>
#defaultStyleMap</styleUrl>
<Point>
<altitudeMode>
relativeToGround</altitudeMode>
<coordinates>
-64.88273,-24.87527,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>
Unnamed Occurence</name>
<Snippet>
Record 10005252</Snippet>
<description>
<![CDATA[<p>
Record <a href="http://mrdata.usgs.gov/mrds/show.php?labno=10005252">
10005252</a>
of the <a href="http://mrdata.usgs.gov/mrds/">
Mineral Resources Data System</a>
</p>
<table border='1' padding='3' cellspacing='0'>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
oper_type</th>
<td>
Unknown</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
dev_stat</th>
<td>
Occurrence</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
ore</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
model</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod1</th>
<td>
Iron</td> ######################Iron here makes it valid
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod2</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod3</th>
<td>
</td>
</tr>
</table>
]]>
</description>
<styleUrl>
#defaultStyleMap</styleUrl>
<Point>
<altitudeMode>
relativeToGround</altitudeMode>
<coordinates>
-64.81607,-24.67527,0</coordinates>
</Point>
</Placemark>
<Placemark>
<name>
Merced I Quarry</name>
<Snippet>
Record 10005254</Snippet>
<description>
<![CDATA[<p>
Record <a href="http://mrdata.usgs.gov/mrds/show.php?labno=10005254">
10005254</a>
of the <a href="http://mrdata.usgs.gov/mrds/">
Mineral Resources Data System</a>
</p>
<table border='1' padding='3' cellspacing='0'>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
oper_type</th>
<td>
Unknown</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
dev_stat</th>
<td>
Producer</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
ore</th>
<td>
Limestone</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
model</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod1</th>
<td>
Limestone, General</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod2</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod3</th>
<td>
</td>
</tr>
</table>
]]>
</description>
<styleUrl>
#ProducerStyleMap</styleUrl>
<Point>
<altitudeMode>
relativeToGround</altitudeMode>
<coordinates>
-65.46052,-24.9586,0</coordinates>
</Point>
</Placemark>
The above sample contains two Placemarks which I have no use for, bracketing one which I need to extract.
Sample 2 (Showing just a 'valid' entry):
(The capture would need to grab all of this)
<Placemark>
<name>
Unnamed Occurence</name>
<Snippet>
Record 10005252</Snippet>
<description>
<![CDATA[<p>
Record <a href="http://mrdata.usgs.gov/mrds/show.php?labno=10005252">
10005252</a>
of the <a href="http://mrdata.usgs.gov/mrds/">
Mineral Resources Data System</a>
</p>
<table border='1' padding='3' cellspacing='0'>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
oper_type</th>
<td>
Unknown</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
dev_stat</th>
<td>
Occurrence</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
ore</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
model</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod1</th>
<td>
Iron</td> ######################Iron here makes it valid
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod2</th>
<td>
</td>
</tr>
<tr valign='top'>
<th align='right' bgcolor='#ddffee'>
commod3</th>
<td>
</td>
</tr>
</table>
]]>
</description>
<styleUrl>
#defaultStyleMap</styleUrl>
<Point>
<altitudeMode>
relativeToGround</altitudeMode>
<coordinates>
-64.81607,-24.67527,0</coordinates>
</Point>
</Placemark>
Update 1:
I got this to work in a regex tester, but I am still working on how to get it into grep et.al.
<Placemark>\n<name>\n.*</name>\n<Snippet>\n.*\n<description>\n(?:(?:.*\n){48}.*Iron.*\n|(?:.*\n){41}.*Iron.*\n|(?:.*\n){35}.*Iron.*\n)(?:.*\n){3,16}\]\]>\n</description>\n(?:.*\n){8,12}</Placemark>
That is trivial with XPath instead regex:
/Placemark[contains(description, "Iron")]
(or /*/Placemark[contains(description, "Iron")] if your xml contains a (required) root element)