Answered by:
ASP>NET ToUpper

Question
-
User-1683022223 posted
i have problem with
code behind on OnRowDataBound
am trying to do ,
if edit == New , = blue color
if edit == update = red
string editing = ((e.Row.FindControl("Labelname") as Label).Text); if (editing.ToString("edit").ToUpper() == "New") { (e.Row.FindControl("Labelname") as Label).ForeColor = Color.Blue; } if (editing.ToString("edit").ToUpper() == "Update") { (e.Row.FindControl("Labelname") as Label).ForeColor = Color.Blue; } }
HTML:
<asp:Label ID="Labelname" runat="server" Text='<%# Eval("edit") %>'></asp:Label>
Thursday, January 21, 2021 7:58 PM
Answers
-
User475983607 posted
i did test it and no change color
There can be other issues with your code. Use the Visual Studio debugger to find the value of the "editing" variable. You can set a break point and execute the code one line at a time all the while viewing the state of every variable.
https://docs.microsoft.com/en-us/visualstudio/debugger/debugger-feature-tour?view=vs-2019
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, January 21, 2021 9:00 PM
All replies
-
User475983607 posted
Assuming there are no errors, ToUpper() makes all the characters upper case.
editing.ToString().ToUpper() == "NEW"
Thursday, January 21, 2021 8:14 PM -
User-1683022223 posted
i did test it and no change color
Thursday, January 21, 2021 8:30 PM -
User475983607 posted
i did test it and no change color
There can be other issues with your code. Use the Visual Studio debugger to find the value of the "editing" variable. You can set a break point and execute the code one line at a time all the while viewing the state of every variable.
https://docs.microsoft.com/en-us/visualstudio/debugger/debugger-feature-tour?view=vs-2019
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, January 21, 2021 9:00 PM