private void BindGrid() { string sortField = VRGrid.Columns[VRGrid.SortColumnIndex].SortField; string sortDirection = VRGrid.SortDirection; DataTable table = GetUserInfoDateTable(); DataView TableView = table.DefaultView; TableView.Sort = String.Format("{0} {1}", sortField, sortDirection); VRGrid.DataSource = TableView; VRGrid.DataBind(); }
/// <summary> /// 行绑定事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void VRGrid_OnPreRowDataBound(object sender, FineUI.GridPreRowEventArgs e) { LinkButtonField lbf = VRGrid.FindColumn("VRdelete") as LinkButtonField; DataRowView row = e.DataItem as DataRowView; string status = row[6].ToString(); if (status == "失效记录") { lbf.Enabled = false; lbf.Icon = FineUI.Icon.None; lbf.ToolTip = "此记录已失效"; } else { lbf.Enabled = true; lbf.Icon = FineUI.Icon.Delete; lbf.ToolTip = "删除此条记录"; } }
/// <summary> /// 数据绑定 /// </summary> private void BindGrid() { string sortField = VRGrid.Columns[VRGrid.SortColumnIndex].SortField; string sortDirection = VRGrid.SortDirection; DateTime starttime = dpStartDate.SelectedDate.Value; DateTime endtime = dpEndDate.SelectedDate.Value; if (!string.IsNullOrEmpty(dpStartDate.Text) && !string.IsNullOrEmpty(dpEndDate.Text) && starttime >= endtime) { FineUI.Alert.Show("结束日期必须大于等于开始日期"); return; } DataTable table = GetUserInfoDateTable(starttime.ToString(), endtime.AddHours(23).AddMinutes(59).ToString()); DataView TableView = table.DefaultView; TableView.Sort = String.Format("{0} {1}", sortField, sortDirection); VRGrid.DataSource = TableView; VRGrid.DataBind(); }