date为null时出错。错误行-DateTime renewalDate = row.Field(“ RenewalDate”);
protected void GrdV_Projects_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow )
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRow row = ((DataRowView)e.Row.DataItem).Row;
DateTime renewalDate = row.Field<DateTime>("RenewalDate");
if (renewalDate.Date > DateTime.Today)
e.Row.Cells[7].BackColor = System.Drawing.ColorTranslator.FromHtml("#669B1F");
else
e.Row.Cells[7].BackColor = System.Drawing.ColorTranslator.FromHtml("#FF8234");
}
}
}
Run Code Online (Sandbox Code Playgroud) 我得到null异常.虽然我直接超过这个页面.我想处理null异常
C#
string json = "";
if (Request.QueryString["data"] !="")
{
json = Request.QueryString["data"];
var req = JsonConvert.DeserializeObject<Request>(json);//getting error in this line
string requestid = req.requestId;
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MYSTRING"].ConnectionString);
SqlCommand cmd = new SqlCommand();
connection.Open();
}
Run Code Online (Sandbox Code Playgroud)
错误
值不能为空.参数名称:value
我在网格视图中有模板字段我想将宽度减少到 20 像素,如何在网格视图中减少或设置模板字段的宽度?
<asp:TemplateField HeaderText="Day Id">
<ItemTemplate>
<asp:Label ID="LblDayId" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "DayId") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblEditDayId" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "DayId") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate >
<asp:TextBox ID="txtAddDayId" runat="server" ReadOnly="true"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
Run Code Online (Sandbox Code Playgroud)