Hi
i want if colum.segment value = 1 then color of colum.bookid should be blue else color of whole line should be yellow
C#
if (Result != null)
{
foreach (var colum in Result)
{
string StudentName = "";
View_SessionDetail Res = bALSessionPlan.GetSessionDetail(Convert.ToInt32(colum.SessionPlanID));
ZoomMeeting Zoom = bALZoom.GetZoomMeetingDetail(Convert.ToInt32(colum.SessionDeliveryCalendarID));
htmlTable.Append("");
htmlTable.Append("" + colum.SessionDeliveryCalendarID + "");
htmlTable.Append("" + colum.BookID + "");
htmlTable.Append("" + colum.SessionID + "");
htmlTable.Append("" + colum.MentorID + "");
htmlTable.Append("" + colum.Segment + "");
htmlTable.Append("");
}
}Thanks

Amit MohantyRank #112 · 20K reputationPosted Jun 1, 2023, 3:52 AM EDT
Try this
if (Result != null) { foreach (var colum in Result) { string StudentName = ""; View_SessionDetail Res = bALSessionPlan.GetSessionDetail(Convert.ToInt32(colum.SessionPlanID)); ZoomMeeting Zoom = bALZoom.GetZoomMeetingDetail(Convert.ToInt32(colum.SessionDeliveryCalendarID)); if (colum.Segment == 1) { htmlTable.Append(""); htmlTable.Append("" + colum.SessionDeliveryCalendarID + ""); htmlTable.Append("" + colum.BookID + ""); htmlTable.Append("" + colum.SessionID + ""); htmlTable.Append("" + colum.MentorID + ""); htmlTable.Append("" + colum.Segment + ""); htmlTable.Append(""); } else { htmlTable.Append(""); htmlTable.Append("" + colum.SessionDeliveryCalendarID + ""); htmlTable.Append("" + colum.BookID + ""); htmlTable.Append("" + colum.SessionID + ""); htmlTable.Append("" + colum.MentorID + ""); htmlTable.Append("" + colum.Segment + ""); htmlTable.Append(""); } } }Ramco RamcoRank #462 · 5.4K reputationPosted Jun 1, 2023, 4:08 AM EDT
Hi Amit
I have condition colum.segment gets evaluated later on but Book Id column is displayed before
Thanks
Ramco RamcoRank #462 · 5.4K reputationPosted Jun 1, 2023, 4:19 AM EDT
Hi Amit
Is it possible that thru Javascript it can be done . It is difficult to change condition evaluation .
Thanks
Amit MohantyRank #112 · 20K reputationPosted Jun 1, 2023, 5:32 AM EDT
Check this example:
var result = [/* Your Result array here */]; if (result != null) { var table = document.getElementById("myTable"); for (var i = 0; i " + colum.SessionDeliveryCalendarID + ""; if (colum.Segment == 1) { var cell = document.createElement("td"); cell.style.backgroundColor = "blue"; cell.appendChild(document.createTextNode(colum.BookID)); row.appendChild(cell); } else { row.style.backgroundColor = "yellow"; row.innerHTML += "" + colum.BookID + ""; } row.innerHTML += "" + colum.SessionID + ""; row.innerHTML += "" + colum.MentorID + ""; row.innerHTML += "" + colum.Segment + ""; table.appendChild(row); } }Rajkiran SwainRank #165 · 14.4K reputationPosted Jun 1, 2023, 2:21 PM EDT
if (Result != null) { foreach (var colum in Result) { string studentName = ""; View_SessionDetail res = bALSessionPlan.GetSessionDetail(Convert.ToInt32(colum.SessionPlanID)); ZoomMeeting zoom = bALZoom.GetZoomMeetingDetail(Convert.ToInt32(colum.SessionDeliveryCalendarID)); string color = colum.Segment == 1 ? "blue" : "yellow"; htmlTable.AppendFormat("", color); htmlTable.AppendFormat("{0}", colum.SessionDeliveryCalendarID); htmlTable.AppendFormat("{1}", colum.Segment == 1 ? "blue" : "inherit", colum.BookID); htmlTable.AppendFormat("{0}", colum.SessionID); htmlTable.AppendFormat("{0}", colum.MentorID); htmlTable.AppendFormat("{0}", colum.Segment); htmlTable.Append(""); } }