I need to print all the code under my question
if there is data in #store.GuaranteePolicy print all the <tr>. If there is no data, then print nothing.
No matter if there is data in or not in #store.GuaranteePolicy, then "Payment" is always printet, but why?
I said that if (store.GuaranteePolicy is different than null, then print)
The if statement is working with this:
If there is data in store.GuaranteePolicy everything is printed perfect
If there is no data in store.GuaranteePolicy the text is not printed, BUT the word Payment: is printed. So the whole <tr> is printed even if it is not true?
#if (store.GuaranteePolicy != null) {
<tr>
<th class="small-12 large-6 columns first">
<table>
<tr>
<th width="300">
<p class="text-left small-text-left"><strong>Payment:</strong></p>
</th>
</tr>
</table>
</th>
<th class="small-12 large-6 columns last">
<table>
<tr>
<th width="300">
<p class="text-left small-text-left">
<span>#store.GuaranteePolicy</span>
</p>
</th>
<th class="expander"></th>
</tr>
</table>
</th>
</tr>
}
If GuaranteePolicy is a collection try this:
#if(store.GuaranteePolicy != null && store.GuaranteePolicy.Count > 0)
{
}
if string:
#if(!string.IsNullOrWhiteSpace(store.GuaranteePolicy))
{
}
and so on...
Related
I am currently working on a project where I want to show a column of a related record (form a sql database). For some of my table this works perfeclty fine, altough for one of them it does not. As shown below, there is no error and the record is filled in with the correct data, but it does not show up correclty. Can anyone help me with this? I tried updating my database already.
<table id="coaches">
<thead>
<tr>
<th>
</th>
<th>
#Html.DisplayNameFor(model => model.Picture)
</th>
<th></th>
</tr>
</thead>
<tbody>
#foreach (var item in Model) {
<tr>
<td>
<img src=#Html.DisplayFor(modelItem => item.Picture) class="person">
</td>
<td>
<div style="padding-left:10px">
<div class="name">#Html.DisplayFor(modelItem => item.Organization.Name)Should be here</div>
<div class="natclub">
<img src="https://dalto.nl/wp-content/uploads/2018/08/dalto-logo.png" class="emblem">
<br>
<img src="https://cdn.countryflags.com/thumbs/netherlands/flag-400.png" class="flag">
</div>
</div>
</td>
</tr>
}
</tbody>
</table>
Organization Table
Coaches table
Page in question
Thanks in advance!
I tried to release a new update of the database using the PM Console, but nothing changed.
I'm trying to get following data.
<html>
<body>
<tr class="udline">
<th rowspan="2" class="noln">시간</th>
<th rowspan="2">개인</th>
<th rowspan="2">외국인</th>
<th rowspan="2">기관계</th>
<th colspan="6" class="eb">기관</th>
<th rowspan="2">기타법인</th>
</tr>
<tr class="udline">
<th class="sub">금융투자</th>
<th class="sub">보험</th>
<th class="sub">투신<br>(사모)</th>
<th class="sub">은행</th>
<th class="sub">기타금융기관</th>
<th class="sub">연기금등</th>
</tr>
<tr>
<td colspan="11" class="blank_07"></td>
</tr>
<!-- following are data -->
<tr>
<td class="date2">18:01</td>
<td class="rate_up3">2,024</td>
<td class="rate_down3">-3,307</td>
<td class="rate_up3">1,116</td>
<td class="rate_up3">824</td>
<td class="rate_down3">-16</td>
<td class="rate_up3">764</td>
<td class="rate_down3">-43</td>
<td class="rate_down3">-5</td>
<td class="rate_down3">-408</td>
<td class="rate_up3">166</td>
</tr>
<tr>
<td class="date2">18:00</td>
<td class="rate_up3">2,022</td>
<td class="rate_down3">-3,305</td>
<td class="rate_up3">1,116</td>
<td class="rate_up3">824</td>
<td class="rate_down3">-16</td>
<td class="rate_up3">764</td>
<td class="rate_down3">-43</td>
<td class="rate_down3">-5</td>
<td class="rate_down3">-408</td>
<td class="rate_up3">166</td>
</tr>
...
</body></html>
I want to get Nodes list of "tr" tag which has a data. but I have problem with getting "tr" tag.
I think it is enough if I can get sets of "tr" which has 11 td tags.
so I write following source.
result = await httpClient.GetStringAsync(new Uri(timeUrlAddress));
htmlDoc.LoadHtml(result);
var nodes =
htmlDoc.DocumentNode.SelectNodes("//tr")
.Where(i => i.ChildNodes.Any(j => j.Name.Equals("td")).Count>10); // <--- I have Problem.
foreach(var i in nodes) { ... } // <-- iterating list of <tr> tags.
and It doesn't work.
I could get List of tr tag with DoucmentNode.SelectNodes("//tr") ... and I appended .Where(i=>i.ChildNodes.Count >10 ) to get what i want.
but tr has several "text"childNodes and I get Unwanted Node. following picture shows that I got with .Where(i=>i.ChildNodes.Count>10).
I want to get tr node that has td tag as child nodes and has exactly 11 of td tag.
how can I get that tr nodes with Linq syntax..?
If you want tr node with exactrly 11 td children you can use below XPath:
//tr[count(td) = 11]
I am using Bootstrap-Table Cn
I have a table. I want to pre-check certain rows. However when I add class="selected" to my or table row, upon loading the table in, Bootstrap-Table removes the class selected and unchecks it. How can I preserve the initial checkbox selected, before the table loads?
Update: I am not creating checkbox inputs. I am using BootStrap Tables CN to generate the checkboxes for me.
Here is the code.
<table id="storeTable" class="table table-bordered table-hover" style="width:100%" data-toggle="table" data-search="true" data-toolbar="#toolbar" data-pagination="true" data-side-pagination="client" data-show-pagination-switch="true" data-page-list="[10, 25, 50, ALL]" data-click-to-select="true" data-filter>
<thead>
<tr>
<th data-sortable="true" data-checkbox="true">
</th>
<th data-field="cg" data-sortable="true">
#Html.DisplayNameFor(model => model.dealeradminstore[0].cg)
</th>
<th data-field="sn" data-sortable="true">
#Html.DisplayNameFor(model => model.dealeradminstore[0].serial_number)
</th>
<th data-field="name" data-sortable="true">
#Html.DisplayNameFor(model => model.dealeradminstore[0].Name)
</th>
<th data-sortable="true">
WebReports
</th>
</tr>
</thead>
<tbody>
#foreach (var item in Model.dealeradminstore)
{
<tr id="#test.NullRefExcl(item.serial_number.ToString())" checked>
<td></td>
<td>
#test.NullRefExcl(item.cg.ToString())
</td>
<td>
#test.NullRefExcl(item.serial_number.ToString())
</td>
<td>
#test.NullRefExcl(item.Name)
</td>
<td>
#{string reportsCheck = "";
if (test.NullRefExcl(item.base_xtags).Contains("RPT"))
{
reportsCheck = "Yes";
}
if (!test.NullRefExcl(item.base_xtags).Contains("RPT"))
{
reportsCheck = "No";
}
}
#test.NullRefExcl(reportsCheck)
</td>
</tr>
}
</tbody>
</table>
To create a dynamically generated checkbox with it's value already set to checked:
#Html.CheckBoxFor(m => m.SomeBooleanProperty, new { #checked = "checked" });
Source: Proper usage of .net MVC Html.CheckBoxFor
Finally with a point in the right direction from Richard0096 I was able to figure it out. Here is the solution that uses the Bootstrap Tables Extensions CN.
var checkSum = 0;
function checkedFormatter(value, row, index) {
var snList = [];
snList = document.getElementById("inputsn").value.split("|");
snList.forEach(function (element) {
var checkSN = ((row.sn).toString()).trim();
if (checkSN == element) {
checkSum = 1;
}
})
if (checkSum == 1) {
checkSum = 0;
return {
checked: true
}
}
return value;
}
This piece of code is failing when I build my project. THe if statement has to check if ParkingLot is true. I thought the way to do that was the following code:
<th class="small-12 large-6 columns last">
<table>
<tr>
<th width="300">
<p class="text-left small-text-left">
#if(Model.Point.Store.JsonDynamic.En.Motel.ParkingLot == True)
{
<span>Possibility for parking</span><br>
}
</p>
</th>
<th class="expander"></th>
</tr>
</table>
</th>
But I get this error:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot
implicitly convert type ''Newtonsoft.Json.Linq.JValue'' to ''bool''.
An explicit conversion exists (are you missing a cast?)
Can anybody see what I am doing wrong here?
Try this
<th class="small-12 large-6 columns last">
<table>
<tr>
<th width="300">
<p class="text-left small-text-left">
#(if((bool)Model.Point.Store.JsonDynamic.En.Motel.ParkingLot == True){<span>Possibility for parking</span><br>})
</p>
</th>
<th class="expander"></th>
</tr>
</table>
</th>
I have one following table html, the data of rows in the table is looped by foreach.
Can I use Razor to get the value of each row into a List or an array in C#?
My C# code Razor (I tried this so far)
#{
var l = new List<string>();
l.Add(#<input id="updated_value2" data-bind="value:value,visible:isEditing()" />);
}
Here's my table
<table class="table table-hover">
<tbody data-bind="foreach: $root.mapJsons(parameters())">
<tr class="data-hover">
<td>
<strong>
<span data-bind="text:key" />
</strong>
</td>
<td>
#*display label and input for dictionary<value> false DIS true APP*#
<input id="updated_value" data-bind="value:value,visible:isEditing()" />
<label id="display_value" data-bind="text:value,visible:!isEditing()" />
</td>
</tr>
</tbody>
<thead>
<tr>
<th style="width: 30%">
Name
</th>
<th style="width: 30%">
Value
</th>
<th></th>
</tr>
</thead>
</table>
Your foreach loop is being executed client-side (looks like a KnockoutJS binding?) rather than server-side, so any Razor code you embed in the table is only going to be called once as it's rendered by the server. So the answer is no, you cannot populate a server-side list with this particular foreach loop.