How to add specific SQL result values to specific cells in a HTML table in Visual Studio 2012
Date : March 29 2020, 07:55 AM
wish help you to fix your issue for the mock, I was wondering how the cell is determined, I didnt explain that well at all! From what you have shown so far I can't think of a control other than a table that will hold that. If there is a set logic behind which cell is used for each value it may be worth doing a custom control.
|
Having Issues creating a loop for HTML table in code and assigning cells for table
Tag : sql , By : PaulPlum
Date : March 29 2020, 07:55 AM
Does that help In your example I don't see why you would need to keep track of the number of cells, as it is now you only add one cell with data from crossover, And the cell is name based witch means you will need to type them out. There is no declaration of strTable, but table is added multiple times, Here is what I would start with: ' If dv.Table.Rows.Count > 0 Then - Not needed since we will get no data from For Each '
Dim sbTable as New System.Text.StringBuilder() ' Faster then concating many strings '
For Each dr As DataRowView In dv
Dim crossover As String = dr("CrossoverID").ToString()
Dim picid As String = dr("Description").ToString()
Dim picdescrip As String = dr("DesignColor").ToString()
sbTable.Append("<tr><td>" & crossover & "</td></tr>") ' Add one line, Separate <tr>, <td> & data & </td>, </tr> to separate lines to add multiple cells '
Next
If sbTable.Length > 0 Then divTable.InnerHtml = "<table style=""border:2;border-width: 1px;"">" & sbTable.ToString() & "</table>"
Dim strTable as New StringBuilder()
Dim itmCounter As Integer = 0
Dim rowIsOpen As Boolean = False
For Each dr As DataRowView In dv
Dim crossover As String = dr("CrossoverID").ToString()
Dim picid As String = dr("Description").ToString()
Dim picdescrip As String = dr("DesignColor").ToString()
' For every 5 items create a new row. '
If itmCounter Mod 5 = 0 Then
' Since we want new row, first close any open row '
If rowIsOpen Then strTable.Append("</tr>")
' Start a new row and mark row as open so we can keep track '
strTable.Append("<tr>")
rowIsOpen = True
End If
strTable.Append("<td><a href=""Breakdown.aspx?p=" & crossover & """>")
strTable.Append("<img src=""Images/" + picid + ".png"" width=""100"" height=""100"" /><br />"))
strTable.Append(picdescrip & "</a></td>")
itmCounter += 1
Next
' Make sure we close any open rows '
If rowIsOpen Then strTable.Append("</tr>")
If sbTable.Length > 0 Then
divTable.InnerHtml = "<table style=""border:2;border-width: 1px;"">" & _
sbTable.ToString() & _
"</table>"
End If
|
Using JQuery/Javascript to insert text into specific cells of a html div table?
Date : March 29 2020, 07:55 AM
around this issue This is a brute-force approach. There are more efficient ways to create this for when you have 100's of rows, but this way is easier to read, especially if you have only 8 rows. First create your grid using row and col classes. <input id="food-input" type="text" placeholder="ENTER A FOOD">
<input id="btn-submit" type="submit">
<div class="row-1">
<div class="col-1"></div>
<div class="col-2"></div>
</div>
<div class="row-2">
<div class="col-1"></div>
<div class="col-2"></div>
</div>
<!-- ...etc, etc. -->
$("#btn-submit").on("click", function(){
var entry = $("#food-input").val();
switch(entry){
case "food-1":
$(".row-1 .col-1").html(entry);
$(".row-1 .col-2").html("380 calories");
break;
case "food-2":
$(".row-2 .col-1").html(entry);
$(".row-2 .col-2").html("125 calories");
break;
//... etc, etc
}
});
|
Loop through table cells of a HTML table with a specific class name
Tag : excel , By : ChrisMe
Date : March 29 2020, 07:55 AM
it helps some times I need to get the data in the cells of a HTML table whose class is myClass using Excel VBA. , You are looping too many times. The code needs to be: For i = 0 To HTMLDoc.Length - 1
For i = 1 To HTMLDoc.Length
|
Put specific values in specific table cells from database. (Razor - html)
Tag : chash , By : Francis
Date : March 29 2020, 07:55 AM
it should still fix some issue var getPR = "SELECT kg, rep, date FROM Test WHERE exerVariName LIKE '%Comp%' AND exercise = @0 order by kg desc";
db.Execute(getPR, i);
var data = db.Query(getPR, i)
@for (var ii = 1; ii <= 12; ii++)
{
var matched = data.SingleOrDefault(x => x.rep == ii);
if (matched != null)
{
DateTime Date = get.Date;
var finalDate = Date.ToString("MMM d, yyyy");
var weight = matched.kg + "kg";
var reps = "x " + matched.rep;
<td class="prTableCell" title="@finalDate">@weight @reps</td>
}
else
{
<td class="prTableCell">0kg</td>
}
}
var getPR = "SELECT kg, rep, date, exercise FROM Test WHERE exerVariName LIKE '%Comp%' order by kg desc";
var matched = data.SingleOrDefault(x => x.exercise == i && x.rep == ii);
|