private void LoadGrid() { Facade.IReferenceData facRef = new Facade.ReferenceData(); DataSet dsLogs = facRef.GetUnsentLogs(); if (dsLogs != null) { if (dsLogs.Tables[0].Rows.Count == 0) { lblError.Text = "No logs require to be sent."; lblError.Visible = true; pnlLogs.Visible = false; } else { DataView dv = new DataView(dsLogs.Tables[0]); if (cboClient.SelectedValue != string.Empty) { if ((dteStartDate.SelectedDate != DateTime.MinValue) || (dteEndDate.SelectedDate != DateTime.MinValue)) { dv.RowFilter = "IdentityId=" + Convert.ToInt32(cboClient.SelectedValue) + " AND DateTimeFrom >= '" + dteStartDate.SelectedDate.Value.ToString("dd/MMM/yyyy HH:mm") + "' AND DateTimeTo <= '" + dteEndDate.SelectedDate.Value.ToString("dd/MMM/yyyy HH:mm") + "'"; dgLogs.DataSource = dv; dgLogs.DataBind(); if (dgLogs.Items.Count == 0) { lblError.Text = "No logs for client " + cboClient.Text + " for period " + dteStartDate.SelectedDate.Value.ToString("dd/MM/yy") + " to " + dteEndDate.SelectedDate.Value.ToString("dd/MM/yy"); lblError.Visible = true; pnlLogs.Visible = false; } else { lblError.Visible = false; pnlLogs.Visible = true; } } else { dv.RowFilter = "IdentityId=" + Convert.ToInt32(cboClient.SelectedValue); dgLogs.DataSource = dv; dgLogs.DataBind(); if (dgLogs.Items.Count == 0) { lblError.Text = "No logs for client " + cboClient.Text + "."; lblError.Visible = true; pnlLogs.Visible = false; } else { lblError.Visible = false; pnlLogs.Visible = true; } } } else { if ((dteStartDate.SelectedDate != DateTime.MinValue) || (dteEndDate.SelectedDate != DateTime.MinValue)) { dv.RowFilter = "DateTimeFrom >= '" + dteStartDate.SelectedDate.Value.ToString("dd/MMM/yyyy HH:mm") + "' AND DateTimeTo <= '" + dteEndDate.SelectedDate.Value.ToString("dd/MMM/yyyy HH:mm") + "'"; dgLogs.DataSource = dv; dgLogs.DataBind(); if (dgLogs.Items.Count == 0) { lblError.Text = "No logs for period " + dteStartDate.SelectedDate.Value.ToString("dd/MM/yy") + " to " + dteEndDate.SelectedDate.Value.ToString("dd/MM/yy");; lblError.Visible = true; pnlLogs.Visible = false; } else { lblError.Visible = false; pnlLogs.Visible = true; } } else { dgLogs.DataSource = dsLogs; dgLogs.DataBind(); lblError.Visible = false; pnlLogs.Visible = true; } } } } }