>>>string strOrderNo = this.txtOrderNo.Text; >>> int? OrderNo; >>> if (strOrderNo.Equals(String.Empty)) >>> OrderNo = null; >>> else >>> OrderNo = Convert.ToInt32(strOrderNo); >>> >>> _dtOrder = biz.Find(OrderNo, this.dtgStartDate.Value, this.dtgEndDate.Value);>>>
>>int? orderNo = null; >>if (!string.IsNullOrEmpty(strOrderNo)) >> orderNo = Convert.ToInt32(strOrderNo); >> >>dtOrder = biz.Find(orderNo, this.dtgStartDate.Value, this.dtgEndDate.Value); >>>Or just
dtOrder = biz.Find((orderNo == String.Empty) ? (int?) null : Convert.ToInt32(orderNo), this.dtgStartDate.Value, this.dtgEndDate.Value);But null converts to zero so you'd probably need:
int? i2 = (orderNo == String.Empty) ? (int?) null : (orderNo==null)? (int?)null : Convert.ToInt32(orderNo);which gets a little less readable. In practice probably better to use TryParse() anyway.....