I’m quite new to the ASP.net Framework Webapps enviroment, and came accross an issue.
If I set a Css class based on a condition in the C# code behind it works perfectly fine. The moment I publish the app to IIS is does not work any more. For sanity I’ve also tried publishing the app as Debug or Release mode, which made no difference.
The data is loaded on the page_load event of the page, and the updatepanel is refreshed here.
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="upcontent">
<ContentTemplate>
<div class="jumbotron" style="padding: 5px; background-color: lightgrey; overflow: hidden">
<div class="card bg-secondary mb-3" style="max-width: 35rem; min-width: 35rem; float: left; overflow: hidden;">
<div class="card-header">Work Order Details</div>
<div class="card-body">
<asp:GridView ID="GVMain" margin-top="10px" runat="server" EmptyDataText="Record is empty" Width="100%" AutoGenerateColumns="true" ShowHeader="false" DataKeyNames="PropertyName" class="table table-hover" OnPageIndexChanging="GVMain_PageIndexChanging" OnRowDataBound="GVMain_RowDataBound" BorderStyle="NotSet" AllowPaging="true" PageSize="10">
<PagerSettings Mode="NumericFirstLast" />
</asp:GridView>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
Code Behind:
protected void GVMain_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// Check the XXXX column - if empty, the YYYY needs highlighting!
if (e.Row.Cells[1].Text == "Mon, 01/01/0001")
{
e.Row.Cells[1].CssClass = "text-warning"; // ...so highlight it
}
}
upcontent.Update();
}
Please assist, see attached images below between dev and deployed enviroment
Not Working when Depoyed on IIS Server
Not Working when Depoyed on IIS Server Inspect Panel
Would it be possible to assist. One thing to note is this is from the same browser on the same PC.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
In this example you give it is not clear what the actual data (type) is. But ideally you would not want to compare with a text representation of a date. Better would be to compare with an actual datetime. So assuming the data you’re binding to is of type SomeObject which has a property DateTime ‘TheDate’ then you could have the following code in the OnRowBinding event:
if (e.Row.RowType == DataControlRowType.DataRow)
{
var value = e.Row.DataItem as SomeObject;
if (value != null && value.TheDate == DateTime.MinValue)
{
// do whatever is appropriate
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0