Datatable Assigning Wrong Values To String While Calling
I have a gridview, in which there are multiple columns and rows. While debugging it generates datatable as below While assigning values for first and second row in html table I ca
Solution 1:
You're using one variable strgrid1
to build your entire table which has only one value when you're doing that, the last value.
You need to build your rows inside the loop:
StrPriBody = StrPriBody + "<table style='width: 100%; height: 53px' border='1'><tr> ";
List<string> titles = newList<string>()
{
"Job Security", "Opportunity for Promotion"// etc..
};
Queue<string> titlesQueue = new Queue<string>(titles);
foreach (DataRow row in dttable2.Rows)
{
string rowTitle = ""; // GET THE TITLE FROM SOME ARRAY OR LIST/** Job security **/if (row["Rating4"].ToString() == "Y")
{
strgrid1 = "Excellent";
}
elseif (row["Rating3"].ToString() == "Y")
{
strgrid1 = "Good";
}
elseif (row["Rating2"].ToString() == "Y")
{
strgrid1 = "Satisfactory";
}
elseif (row["Rating1"].ToString() == "Y")
{
strgrid1 = "Poor";
}
StrPriBody = StrPriBody +
"<td style='width: 100px; height: 14px;background-color:" + strcolordet + " ;white-space:nowrap'><strong>" + titlesQueue.Dequeue() + "</strong></td> " +
"<td style='width: 100px; height: 14px;background-color:" + strcolordet + "'>" + strgrid1 + "</td><br /> ";
}
StrPriBody += "<table/>";
Post a Comment for "Datatable Assigning Wrong Values To String While Calling"