public void Copy () { DataGridItemCollection c; ArrayList list; DataGridItem[] copy; DataGridItem item; list = new ArrayList(); item = new DataGridItem(0, 0, ListItemType.Item); list.Add(item); item = new DataGridItem(1, 1, ListItemType.Header); list.Add(item); item = new DataGridItem(2, 2, ListItemType.Footer); list.Add(item); c = new DataGridItemCollection(list); copy = new DataGridItem[3]; Assert.AreEqual(3, c.Count, "C1"); c.CopyTo(copy, 0); Assert.AreEqual(3, copy.Length, "C2"); copy = new DataGridItem[4]; c.CopyTo(copy, 1); Assert.AreEqual(4, copy.Length, "C3"); }
private TechnologyStandardCollectin GetSelect() { TechnologyStandardCollectin technologyStandardCollectin = new TechnologyStandardCollectin(); ArrayList arrayList = new ArrayList(); int maxId = TechnologyStandardAction.GetMaxId(); for (int i = 0; i < this.DGrdStandard.Items.Count; i++) { System.Web.UI.WebControls.DataGridItem dataGridItem = this.DGrdStandard.Items[i]; System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)dataGridItem.Cells[6].FindControl("CHK"); if (checkBox.Checked) { TechnologyStandardInfo technologyStandardInfo = new TechnologyStandardInfo(); technologyStandardInfo.TechnologyCriterion = int.Parse(this.DGrdStandard.DataKeys[i].ToString()); technologyStandardInfo.MainId = maxId + i; technologyStandardInfo.PrjCode = this.ViewState["PRJCODE"].ToString(); technologyStandardInfo.TechnologyCriterionID = dataGridItem.Cells[1].Text.ToString(); technologyStandardInfo.TechnologyClassify = dataGridItem.Cells[4].Text.ToString(); technologyStandardInfo.TechnologyName = dataGridItem.Cells[3].Text.ToString(); technologyStandardInfo.TechnologyPromulgateTime = dataGridItem.Cells[2].Text.ToString(); technologyStandardInfo.Remark = dataGridItem.Cells[5].Text.ToString(); technologyStandardCollectin.Add(technologyStandardInfo); arrayList.Add(technologyStandardInfo.MainId); } } this.ViewState["list"] = arrayList; return(technologyStandardCollectin); }
public DNNDataGridCheckChangedEventArgs( DataGridItem item, bool isChecked, string field, bool isAll ) : base( item ) { this.mIsAll = false; this.mChecked = isChecked; this.mIsAll = isAll; this.mField = field; }
private void Insert(DataGridItem e) { try { TextBox txtName = e.FindControl("txtName") as TextBox; TextBox txtAddress = e.FindControl("txtAddress") as TextBox; DropDownList ddlType = e.FindControl("ddlType") as DropDownList; List<SqlParameter> pars = new List<SqlParameter>(); pars.Add(new SqlParameter("@Name", txtName.Text)); pars.Add(new SqlParameter("@Address", txtAddress.Text)); pars.Add(new SqlParameter("@Type", ddlType.SelectedValue)); DBHelper.ExecuteNonQuery("sp_Support_AddNew", pars); Notify.ShowAdminMessageSuccess("Thêm mới thành công", this.Page); dtgSupport.CurrentPageIndex = 0; LoadGrid(); } catch { Notify.ShowAdminMessageError("Lỗi", this.Page); LoadGrid(); return; } }
public static string CodeToText(DataGridItem GridItem, string ColumnName, string TextCol) { if ((GridItem.DataItem is DataRowView)) return CodeToText((DataRowView)GridItem.DataItem, ColumnName, TextCol, false); if ((GridItem.DataItem is DataRow)) return CodeToText((DataRow)GridItem.DataItem, ColumnName, TextCol, false); return ""; }
protected string GetPQUsage(DataGridItem Container) { MultiXTpmDB.GroupStatusRow Row = (MultiXTpmDB.GroupStatusRow)((DataRowView)Container.DataItem).Row; if(Row.MaxProcessQueueEntries > 0) return ((int)((Row.OutQueueSize * 100) / Row.MaxProcessQueueEntries)).ToString() + "%"; else return "0%"; }
protected string GetOpenModeText(DataGridItem Container) { string SSL = ""; MultiXTpmDB.LinkRow Row = (MultiXTpmDB.LinkRow)((DataRowView)Container.DataItem).Row; if (Row.SSLAPI == MultiXTpm.SSL_API.OpenSSL.ToString()) SSL = "/" + Row.SSLAPI; if(Row.OpenMode == (int)MultiXTpm.MultiXOpenMode.MultiXOpenModeClient) return "Client/Connect" + SSL; if(Row.OpenMode == (int)MultiXTpm.MultiXOpenMode.MultiXOpenModeServer) return "Server/Listen" + SSL; return "UnKnown"; }
protected string GetPortText(DataGridItem Container) { MultiXTpmDB.LinkRow Row = (MultiXTpmDB.LinkRow)((DataRowView)Container.DataItem).Row; if(Row.OpenMode == (int)MultiXTpm.MultiXOpenMode.MultiXOpenModeClient) { return Row.IsRemotePortNull() || Row.RemotePort.Trim().Length == 0 ? "Unknown" : Row.RemotePort; } if(Row.OpenMode == (int)MultiXTpm.MultiXOpenMode.MultiXOpenModeServer) { return Row.IsLocalPortNull() || Row.LocalPort.Trim().Length == 0 ? "Automatic" : Row.LocalPort; } return "Unknown"; }
public void created(object sender ,DataGridItemEventArgs e) { if(e.Item.ItemType == ListItemType.Footer && grid.Items.Count==0) { Control /*DataGridTable*/ table = grid.Controls[0]; DataGridItem tr = new DataGridItem(0,0,ListItemType.Item); TableCell td = new TableCell(); td.ColumnSpan = table.Controls[0].Controls.Count;//no of cols on header td.Text = "No records"; td.HorizontalAlign = HorizontalAlign.Center; tr.Controls.Add(td); table.Controls.Add(tr);//controls[0]=table } }
protected string GetProcessStatusText(DataGridItem Container) { MultiXTpmDB.ProcessStatusRow Row; if(Container.DataItem is DataRowView) Row = (MultiXTpmDB.ProcessStatusRow)((DataRowView)Container.DataItem).Row; else Row = (MultiXTpmDB.ProcessStatusRow)Container.DataItem; if(Row.IsReady) { if(Row.ControlStatus == (int)MultiXTpm.ProcessControlStatus.Normal) return "Running"; return "Running (" + ((MultiXTpm.ProcessControlStatus)Row.ControlStatus).ToString("g") + ")"; } return "Stopped (" + ((MultiXTpm.ProcessControlStatus)Row.ControlStatus).ToString("g") + ")"; }
public void Defaults () { DataGridItem i; string s; i = new DataGridItem(123, 456, ListItemType.Pager); s = "blah"; i.DataItem = s; Assert.AreEqual(ListItemType.Pager, i.ItemType, "D1"); Assert.AreEqual(456, i.DataSetIndex, "D2"); Assert.AreEqual(123, i.ItemIndex, "D3"); Assert.AreEqual(s, i.DataItem, "D4"); Assert.AreEqual("blah", i.DataItem, "D5"); }
private void Delete(DataGridItem e) { try { string id = (e.FindControl("lblId") as Label).Text; List<SqlParameter> pars = new List<SqlParameter>(); pars.Add(new SqlParameter("@Id", id)); DBHelper.ExecuteNonQuery("sp_Video_Delete", pars); Notify.ShowAdminMessageSuccess("Đã xóa", this.Page); dtgVideo.CurrentPageIndex = 0; LoadGrid(); Response.Redirect("VideoManager.aspx"); } catch { Response.Redirect("VideoManager.aspx"); } }
/// <include file='doc\ButtonColumn.uex' path='docs/doc[@for="ButtonColumn.OnDataBindColumn"]/*' /> /// <devdoc> /// </devdoc> private void OnDataBindColumn(object sender, EventArgs e) { Debug.Assert(DataTextField.Length != 0, "Shouldn't be DataBinding without a DataTextField"); Control boundControl = (Control)sender; DataGridItem item = (DataGridItem)boundControl.NamingContainer; object dataItem = item.DataItem; if (textFieldDesc == null) { string dataField = DataTextField; textFieldDesc = TypeDescriptor.GetProperties(dataItem).Find(dataField, true); if ((textFieldDesc == null) && !DesignMode) { throw new HttpException(HttpRuntime.FormatResourceString(SR.Field_Not_Found, dataField)); } } string dataValue; if (textFieldDesc != null) { object data = textFieldDesc.GetValue(dataItem); dataValue = FormatDataTextValue(data); } else { Debug.Assert(DesignMode == true); dataValue = SR.GetString(SR.Sample_Databound_Text); } if (boundControl is LinkButton) { ((LinkButton)boundControl).Text = dataValue; } else { Debug.Assert(boundControl is Button, "Expected the bound control to be a Button"); ((Button)boundControl).Text = dataValue; } }
public void Defaults () { DataGridItemCollection c; ArrayList list; DataGridItem item; list = new ArrayList(); item = new DataGridItem(0, 0, ListItemType.Item); list.Add(item); c = new DataGridItemCollection(list); Assert.AreEqual(1, c.Count, "D1"); Assert.AreEqual(item, c[0], "D2"); // Copy or ref? item = new DataGridItem(1, 1, ListItemType.Header); list.Add(item); Assert.AreEqual(2, c.Count, "D3"); Assert.AreEqual(ListItemType.Header, c[1].ItemType, "D4"); }
public static Control GetControlFromDataGrid(DataGridItem row, Type type, int cellindex, int controlindex) { if (row.ItemType == ListItemType.Item || row.ItemType == ListItemType.AlternatingItem) { for (int i = 0; i < row.Cells[cellindex].Controls.Count; i++) { if(type.Equals(row.Cells[cellindex].Controls[i].GetType())) { if (0 == controlindex) { return row.Cells[cellindex].Controls[i]; } else { controlindex--; } } } } return null; }
private void Insert(DataGridItem e) { try { string url = (e.FindControl("txtUrl") as TextBox).Text; string detail = (e.FindControl("txtDetail") as TextBox).Text; List<SqlParameter> pars = new List<SqlParameter>(); pars.Add(new SqlParameter("@Url", url)); pars.Add(new SqlParameter("@Detail", detail)); DBHelper.ExecuteNonQuery("sp_Video_AddNew", pars); Notify.ShowAdminMessageSuccess("Thêm mới thành công", this.Page); dtgVideo.CurrentPageIndex = 0; LoadGrid(); } catch { Notify.ShowAdminMessageError("Lỗi", this.Page); LoadGrid(); return; } }
public Token(DataGridItem dgi) { _TokenID = Convert.ToInt32(((Label) dgi.FindControl("lblTokenID")).Text); _TokenAlias = ((Label) dgi.FindControl("lblTokenName")).Text; _Hidden = ! ((CheckBox) dgi.FindControl("chkHidden")).Checked; _DataType = (QuickReport.DataTypes) Convert.ToInt32(((Label) dgi.FindControl("lblDataTypeID")).Text); _TokenType = (QuickReport.TokenTypes) Convert.ToInt32(((Label) dgi.FindControl("lblTokenTypeID")).Text); _Function = ((DropDownList) dgi.FindControl("ddlFunction")).SelectedValue; SortBy = ((CheckBox) dgi.FindControl("chkColumnSort")).Checked; SortDirection = ((DropDownList) dgi.FindControl("ddlColumnSortDirection")).SelectedValue; SingleDate = ((CalendarPopup) dgi.FindControl("dtParameter")).SelectedDate; DateFrom = ((CalendarPopup) dgi.FindControl("dtParameterFrom")).SelectedDate; DateTo = ((CalendarPopup) dgi.FindControl("dtParameterTo")).SelectedDate; SingleText = ((TextBox) dgi.FindControl("txtExpression")).Text; strFrom = ((TextBox) dgi.FindControl("txtFrom")).Text; strTo = ((TextBox) dgi.FindControl("txtTo")).Text; ActiveValue = ((RadioButtonList) dgi.FindControl("lstActive")).SelectedValue; _TokenOrder = Convert.ToInt32(((Label) dgi.FindControl("lblTokenOrder")).Text); }
public DataGridCommandEventArgs(DataGridItem item, Object commandSource, CommandEventArgs originalArgs) : base(default(CommandEventArgs)) { }
protected virtual new void InitializeItem(DataGridItem item, DataGridColumn[] columns) { }
/* /// <summary> /// /// </summary> /// <param name="itemIndex"></param> /// <param name="cellIndex"></param> /// <param name="text"></param> /// <remark>�ѷ�������Ϊ��OnDataBind�¼��ڲ���ʹ�ô˷�����</remark> public void SetItemText(int itemIndex, int cellIndex, string text) { if(this.Items[itemIndex].Cells[cellIndex].Controls.Count >= 0) (this.Items[itemIndex].Cells[cellIndex].Controls[0] as HyperLink).Text = text; } public void SetItemText(int itemIndex, string cellFieldName, string text) { int cellIndex = this.FindColumnIndex(cellFieldName); if(cellIndex>=0) this.SetItemText(itemIndex, cellIndex, text); } */ /// <summary> /// ��ָ���и�ֵ�� /// </summary> /// <param name="item">�����ô��ݣ�����ֱ���Ķ�ӦItem��ֵ��</param> /// <param name="cellIndex"></param> /// <param name="text"></param> public void SetItemText(DataGridItem item, int cellIndex, string text) { if(item.Cells[cellIndex].Controls.Count >= 0) (item.Cells[cellIndex].Controls[0] as HyperLink).Text = text; }
/* /// <summary> /// ��ȡָ���С�ָ����Ԫ������ݡ� /// </summary> /// <param name="itemIndex"></param> /// <param name="cellIndex"></param> /// <returns></returns> /// <remark>�ѷ�������Ϊ��OnDataBind�¼��ڲ���ʹ�ô˷�����</remark> public string GetItemText(int itemIndex, int cellIndex) { DataGridItem item = this.Items[itemIndex]; //�˴����� HyperLink link = null; if(item.Cells[cellIndex].Controls.Count >= 0) link = item.Cells[cellIndex].Controls[0] as HyperLink; return link==null?"":link.Text; } public string GetItemText(int itemIndex, string cellFieldName) { int cellIndex = this.FindColumnIndex(cellFieldName); return cellIndex>=0?this.GetItemText(itemIndex, cellIndex):""; } */ public string GetItemText(DataGridItem item, int cellIndex) { HyperLink link = null; if(item.Cells[cellIndex].Controls.Count >= 0) link = item.Cells[cellIndex].Controls[0] as HyperLink; return link==null?"":link.Text; }
private string GetExpression(DataGridItem dgi) { QuickReport.DataTypes _DataType = (QuickReport.DataTypes) Convert.ToInt32(((Label) dgi.FindControl("lblDataTypeID")).Text); string Function = ((DropDownList) dgi.FindControl("ddlFunction")).SelectedValue; DateTime dtSingle = ((CalendarPopup) dgi.FindControl("dtExpression")).SelectedDate; DateTime DateFrom = ((CalendarPopup) dgi.FindControl("dtFrom")).SelectedDate; DateTime DateTo = ((CalendarPopup) dgi.FindControl("dtTo")).SelectedDate; string ActiveValue = ((RadioButtonList) dgi.FindControl("rblActive")).SelectedValue; string strSingle = ((TextBox) dgi.FindControl("txtExpression")).Text; string strFrom = ((TextBox) dgi.FindControl("txtFrom")).Text; string strTo = ((TextBox) dgi.FindControl("txtTo")).Text; string Expression = ""; switch(_DataType) { case QuickReport.DataTypes.DateTime: { if (Function == "between") { if (DateFrom != DateTime.MinValue) { Expression = "'" + DateFrom.ToString() + "'"; } else { Expression = "'" + DateTime.MinValue.ToString() + "'"; } Expression += "|"; if (DateTo != DateTime.MinValue) { Expression += "'" + DateTo.ToString() + "'"; } else { Expression += "'" + DateTime.MaxValue.ToString() + "'"; } } else { if (dtSingle != DateTime.MinValue) { Expression = "'" + dtSingle.ToString() + "'"; } else { Expression = "'" + DateTime.MinValue.ToString() + "'"; } } break; } case QuickReport.DataTypes.Boolean: { Expression = ActiveValue; break; } default: { if (Function == "between") { Expression = "'" + strFrom + "'|'" + strTo + "'"; } else { Expression = "'" + strSingle + "'"; } break; } } return Expression; }
protected void SetValueColumnVisiblity(DataGridItem item) { HtmlGenericControl divtxtExpression = (HtmlGenericControl) item.FindControl("divtxtExpression"); HtmlGenericControl divdtExpression = (HtmlGenericControl) item.FindControl("divdtExpression"); HtmlGenericControl divrblActive = (HtmlGenericControl) item.FindControl("divrblActive"); HtmlGenericControl divtxtRange = (HtmlGenericControl) item.FindControl("divtxtRange"); HtmlGenericControl divdtRange = (HtmlGenericControl) item.FindControl("divdtRange"); DropDownList ddlFunction = (DropDownList) item.FindControl("ddlFunction"); divtxtExpression.Attributes["style"] = "display:none"; divdtExpression.Attributes["style"] = "display:none"; divrblActive.Attributes["style"] = "display:none"; divtxtRange.Attributes["style"] = "display:none"; divdtRange.Attributes["style"] = "display:none"; if (((Label) item.FindControl("lblDataTypeID")).Text != "") { QuickReport.DataTypes dataType = (QuickReport.DataTypes) Convert.ToInt32(((Label) item.FindControl("lblDataTypeID")).Text); switch(dataType) { case QuickReport.DataTypes.DateTime: { divtxtExpression.Visible = false; divtxtRange.Visible = false; divrblActive.Visible = false; if (ddlFunction.SelectedValue == "-1") { ClearColumn(item); } else if (ddlFunction.SelectedValue == "between") { divdtRange.Attributes["style"] = "display:block"; } else { divdtExpression.Attributes["style"] = "display:block"; } break; } case QuickReport.DataTypes.Boolean: { divtxtExpression.Visible = false; divdtExpression.Visible = false; divtxtRange.Visible = false; divdtRange.Visible = false; if (ddlFunction.SelectedValue == "-1") { ClearColumn(item); } else { divrblActive.Attributes["style"] = "display:block"; } break; } case QuickReport.DataTypes.Integer: case QuickReport.DataTypes.String: { divdtExpression.Visible = false; divdtRange.Visible = false; divrblActive.Visible = false; if (ddlFunction.SelectedValue == "-1") { ClearColumn(item); } else if (ddlFunction.SelectedValue == "between") { divtxtRange.Attributes["style"] = "display:block"; } else { divtxtExpression.Attributes["style"] = "display:block"; } break; } } } }
/// <summary> /// Method that HTML Encodes an entire DataGrid. /// It iterates through each cell in the TableRow, ensuring that all /// the text being displayed is HTML Encoded, irrespective of whether /// they are just plain text, buttons, hyperlinks, multiple controls etc.. /// <seealso cref="System.Web.UI.WebControls.DataGrid.ItemDataBound">DataGrid.ItemDataBound Event</seealso> /// </summary> /// <param name="item"> /// The DataGridItem that is currently being bound in the calling Web /// Page's DataGrid.ItemDataBound Event. /// </param> /// <remarks> /// This method should be called from the /// <c>DataGrid_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)</c> /// event in the respective Web View Codebehind. /// </remarks> /// <example> /// We want to HTMLEncode a complete DataGrid (all columns and all /// rows that may/do contain characters that will require encoding /// for display in HTML) called dgIssues. /// Use the following code for the ItemDataBound Event: /// <code> /// private void dgIssues_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) /// { /// WebMethod wm = new WebMethod(); /// wm.DataGrid_ItemDataBound_HTMLEncode((DataGridItem) e.Item); /// }//dgIssues_ItemDataBound /// </code> /// </example> public void AdHocHTMLEncode(System.Web.UI.WebControls.DataGridItem item) { bool doHTMLEncode = false; switch (item.ItemType) { #region DataBound //The following case statements are in ascending TableItemStyle order. //See ms-help://MS.VSCC/MS.MSDNVS/cpref/html/frlrfsystemwebuiwebcontrolsdatagridclassitemstyletopic.htm for details. case System.Web.UI.WebControls.ListItemType.Item: { doHTMLEncode = true; break; } //ListItemType.Item case System.Web.UI.WebControls.ListItemType.AlternatingItem: { doHTMLEncode = true; break; } //ListItemType.AlternatingItem case System.Web.UI.WebControls.ListItemType.SelectedItem: { doHTMLEncode = true; break; } //ListItemType.SelectedItem case System.Web.UI.WebControls.ListItemType.EditItem: { //These should not be prone to this as TextBoxes aren't. doHTMLEncode = false; break; } //ListItemType.EditItem #endregion DataBound #region Non-DataBound //The remainder are the other ListItemTypes that are non-Data-bound. case System.Web.UI.WebControls.ListItemType.Header: { //We might have specified Headers like "<ID>". doHTMLEncode = true; break; } //ListItemType.Header case System.Web.UI.WebControls.ListItemType.Footer: { //Similarly for the Footer as with the Header. doHTMLEncode = true; break; } //ListItemType.Footer case System.Web.UI.WebControls.ListItemType.Pager: { //With just numbers or buttons, none is required. //However, for buttons, this is not strictly true as you //need to specify the text on the buttons. But the Property //Builder for the DataGrid hints in its defaults that these //need to be HTMLencoded anyway. doHTMLEncode = false; break; } //ListItemType.Pager case System.Web.UI.WebControls.ListItemType.Separator: { doHTMLEncode = false; break; } //ListItemType.Separator #endregion Non-DataBound default: { //This will never be executed as all ItemTypes are listed above. break; } //default } //switch if (doHTMLEncode) { //Encode the cells dependent on the type of content //within (e.g. BoundColumn, Hyperlink), taking into account //that there may be more than one (or even zero) control in //each cell. System.Web.UI.WebControls.TableCellCollection cells = (System.Web.UI.WebControls.TableCellCollection)item.Cells; foreach (System.Web.UI.WebControls.TableCell cell in cells) { if (cell.Controls.Count != 0) { foreach (System.Web.UI.Control ctrl in cell.Controls) { if (ctrl is Button) { Button btn = (Button)ctrl; btn.Text = HttpUtility.HtmlEncode(btn.Text); } //if else if (ctrl is HyperLink) { HyperLink hyp = (HyperLink)ctrl; hyp.Text = HttpUtility.HtmlEncode(hyp.Text); //hyp.NavigateUrl = HttpUtility.UrlEncode(hyp.NavigateUrl); } //else if else if (ctrl is LinkButton) { LinkButton lb = (LinkButton)ctrl; lb.Text = HttpUtility.HtmlEncode(lb.Text); } //else if // this check is for to change the forecolor of REJECTED activities to red else if (ctrl is Label) { Label objL = (Label)ctrl; if (objL.Text == "REJECTED") { objL.ForeColor = System.Drawing.Color.Red; } } //else if } //foreach } //if else { //The cell is a BoundColumn. if (cell.Text.ToLower().Trim() != " ") { cell.Text = HttpUtility.HtmlEncode(cell.Text); } } //else } //foreach } //if } //DataGrid_ItemDataBound_HTMLEncode
public DataGridItemEventArgs(DataGridItem item) { this.item = item; }
public DataGridCommandEventArgs(DataGridItem item, Object commandSource, CommandEventArgs originalArgs) : base(default(CommandEventArgs)) { Contract.Ensures(originalArgs.CommandName.Length >= 0); }
public DataGridCommandEventArgs(DataGridItem item, object commandSource, CommandEventArgs originalArgs) : base(originalArgs) { this.item = item; this.commandSource = commandSource; }
public void FillDataGridItem(DataGridItem dgi) { ((Label) dgi.FindControl("lblDataTypeID")).Text = Convert.ToInt32(_DataType).ToString(); ((Label) dgi.FindControl("lblTokenTypeID")).Text = Convert.ToInt32(_TokenType).ToString(); ((DropDownList) dgi.FindControl("ddlFunction")).SelectedValue = Function; ((RadioButtonList) dgi.FindControl("lstActive")).SelectedValue = ActiveValue; ((CalendarPopup) dgi.FindControl("dtParameter")).SelectedDate = SingleDate; ((CalendarPopup) dgi.FindControl("dtParameterFrom")).SelectedDate = DateFrom; ((CalendarPopup) dgi.FindControl("dtParameterTo")).SelectedDate = DateTo; ((TextBox) dgi.FindControl("txtExpression")).Text = SingleText; ((TextBox) dgi.FindControl("txtFrom")).Text = strFrom; ((TextBox) dgi.FindControl("txtTo")).Text = strTo; ((CheckBox) dgi.FindControl("chkColumnSort")).Checked = SortBy; ((DropDownList) dgi.FindControl("ddlColumnSortDirection")).SelectedValue = SortDirection; }
protected void SetValueColumnVisiblity(DataGridItem item) { QuickReport.DataTypes dataType = (QuickReport.DataTypes) Convert.ToInt32(((Label) item.FindControl("lblDataTypeID")).Text); DropDownList ddlFunction = (DropDownList) item.FindControl("ddlFunction"); TextBox txtExpression = (TextBox) item.FindControl("txtExpression"); RadioButtonList rbl = (RadioButtonList) item.FindControl("lstActive"); CalendarPopup dtParameter = (CalendarPopup) item.FindControl("dtParameter"); CalendarPopup dtParameterTo = (CalendarPopup) item.FindControl("dtParameterTo"); CalendarPopup dtParameterFrom = (CalendarPopup) item.FindControl("dtParameterFrom"); Label lblFrom = (Label) item.FindControl("lblFrom"); Label lblTo = (Label) item.FindControl("lblTo"); TextBox txtFrom = (TextBox) item.FindControl("txtFrom"); TextBox txtTo = (TextBox) item.FindControl("txtTo"); rbl.Visible = false; dtParameter.Visible = false; dtParameterFrom.Visible = false; dtParameterTo.Visible = false; lblFrom.Visible = false; lblTo.Visible = false; txtExpression.Visible = false; txtFrom.Visible = false; txtTo.Visible = false; switch(dataType) { case QuickReport.DataTypes.DateTime: { if (ddlFunction.SelectedValue == "-1") {} else if (ddlFunction.SelectedValue == "between") { lblFrom.Visible = true; lblTo.Visible = true; dtParameterTo.Visible = true; dtParameterFrom.Visible = true; } else { dtParameter.Visible = true; } break; } case QuickReport.DataTypes.Boolean: { if (ddlFunction.SelectedValue == "-1") {} else { rbl.Visible = true; } break; } case QuickReport.DataTypes.Integer: case QuickReport.DataTypes.String: { if (ddlFunction.SelectedValue == "-1") {} else if (ddlFunction.SelectedValue == "between") { lblFrom.Visible = true; lblTo.Visible = true; txtFrom.Visible = true; txtTo.Visible = true; } else { txtExpression.Visible = true; } break; } } }
public void InitializePager () { DataGridPoker p = new DataGridPoker (); PagedDataSource paged = new PagedDataSource (); DataTable table = new DataTable (); DataGridItem item = new DataGridItem (-1, -1, ListItemType.Pager); ArrayList columns; LinkButton next; LinkButton prev; table.Columns.Add (new DataColumn ("one", typeof (string))); table.Columns.Add (new DataColumn ("two", typeof (string))); table.Columns.Add (new DataColumn ("three", typeof (string))); for (int i = 0; i < 25; i++) table.Rows.Add (new object [] { "1", "2", "3" }); paged.DataSource = new DataView (table); columns = p.CreateColumns (paged, true); p.InitPager (item, columns.Count, paged); // // No where to go // Assert.AreEqual (item.Controls.Count, 1, "A1"); Assert.AreEqual (item.Controls [0].GetType (), typeof (TableCell), "A2"); Assert.AreEqual (item.Controls [0].Controls.Count, 3, "A3"); Assert.AreEqual (item.Controls [0].Controls [0].GetType (), typeof (Label), "A4"); Assert.AreEqual (item.Controls [0].Controls [1].GetType (), typeof (LiteralControl), "A5"); Assert.AreEqual (item.Controls [0].Controls [2].GetType (), typeof (Label), "A6"); Assert.AreEqual (((Label) item.Controls [0].Controls [0]).Text, "<", "A7"); Assert.AreEqual (((LiteralControl) item.Controls [0].Controls [1]).Text, " ", "A7"); Assert.AreEqual (((Label) item.Controls [0].Controls [2]).Text, ">", "A8"); // // Next // item = new DataGridItem (-1, -1, ListItemType.Pager); paged.PageSize = 5; paged.VirtualCount = 25; paged.AllowPaging = true; p.InitPager (item, columns.Count, paged); Assert.AreEqual (item.Controls.Count, 1, "A9"); Assert.AreEqual (item.Controls [0].GetType (), typeof (TableCell), "A10"); Assert.AreEqual (item.Controls [0].Controls.Count, 3, "A11"); Assert.AreEqual (item.Controls [0].Controls [0].GetType (), typeof (Label), "A12"); Assert.AreEqual (item.Controls [0].Controls [1].GetType (), typeof (LiteralControl), "A13"); Assert.AreEqual (((Label) item.Controls [0].Controls [0]).Text, "<", "A14"); Assert.AreEqual (((LiteralControl) item.Controls [0].Controls [1]).Text, " ", "A16"); next = (LinkButton) item.Controls [0].Controls [2]; Assert.AreEqual (next.Text, ">", "A17"); Assert.AreEqual (next.CommandName, "Page", "A18"); Assert.AreEqual (next.CommandArgument, "Next", "A19"); // // Both // item = new DataGridItem (-1, -1, ListItemType.Pager); paged.PageSize = 5; paged.VirtualCount = 25; paged.AllowPaging = true; paged.CurrentPageIndex = 2; p.InitPager (item, columns.Count, paged); Assert.AreEqual (item.Controls.Count, 1, "A20"); Assert.AreEqual (item.Controls [0].GetType (), typeof (TableCell), "A21"); Assert.AreEqual (item.Controls [0].Controls.Count, 3, "A22"); Assert.AreEqual (item.Controls [0].Controls [1].GetType (), typeof (LiteralControl), "A23"); Assert.AreEqual (((LiteralControl) item.Controls [0].Controls [1]).Text, " ", "A24"); // This is failing with an invalidcast right now. It's something related to // the pager thinking that it's on the last page and rendering a label instead next = (LinkButton) item.Controls [0].Controls [2]; Assert.AreEqual (next.Text, ">", "A25"); Assert.AreEqual (next.CommandName, "Page", "A26"); Assert.AreEqual (next.CommandArgument, "Next", "A27"); prev = (LinkButton) item.Controls [0].Controls [0]; Assert.AreEqual (prev.Text, "<", "A28"); Assert.AreEqual (prev.CommandName, "Page", "A29"); Assert.AreEqual (prev.CommandArgument, "Prev", "A30"); // // Back only // item = new DataGridItem (-1, -1, ListItemType.Pager); paged.PageSize = 5; paged.VirtualCount = 25; paged.AllowPaging = true; paged.CurrentPageIndex = 4; p.InitPager (item, columns.Count, paged); Assert.AreEqual (item.Controls.Count, 1, "A31"); Assert.AreEqual (item.Controls [0].GetType (), typeof (TableCell), "A32"); Assert.AreEqual (item.Controls [0].Controls.Count, 3, "A33"); Assert.AreEqual (item.Controls [0].Controls [1].GetType (), typeof (LiteralControl), "A34"); Assert.AreEqual (item.Controls [0].Controls [2].GetType (), typeof (Label), "A35"); Assert.AreEqual (((LiteralControl) item.Controls [0].Controls [1]).Text, " ", "A36"); Assert.AreEqual (((Label) item.Controls [0].Controls [2]).Text, ">", "A37"); prev = (LinkButton) item.Controls [0].Controls [0]; Assert.AreEqual (prev.Text, "<", "A38"); Assert.AreEqual (prev.CommandName, "Page", "A39"); Assert.AreEqual (prev.CommandArgument, "Prev", "A40"); }
private void GetSort(DataGridItem dgi, string[] holder, string columnName) { string Sort = ""; int order = 0; if (((CheckBox) dgi.FindControl("chkColumnSort")).Checked) { order = Convert.ToInt32(((HtmlInputHidden) dgi.FindControl("hdnSortOrder")).Value); Sort = ((DropDownList) dgi.FindControl("ddlColumnSortDirection")).SelectedValue; holder[order-1] = "[" + columnName + "] " + Sort; } }
public void BubbleEvent () { DataGridPoker p = new DataGridPoker (); DataGridCommandEventArgs command_args; // // Cancel // ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("Cancel", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.CancelCommand += new DataGridCommandEventHandler (CancelCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (cancel_command, "A1"); Assert.IsTrue (item_command, "#01"); ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("cancel", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.CancelCommand += new DataGridCommandEventHandler (CancelCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (cancel_command, "A2"); Assert.IsTrue (item_command, "#02"); ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("CANCEL", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.CancelCommand += new DataGridCommandEventHandler (CancelCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (cancel_command, "A3"); Assert.IsTrue (item_command, "#03"); // // Delete // ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("Delete", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.DeleteCommand += new DataGridCommandEventHandler (DeleteCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (delete_command, "A4"); Assert.IsTrue (item_command, "#04"); ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("delete", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.DeleteCommand += new DataGridCommandEventHandler (DeleteCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (delete_command, "A5"); Assert.IsTrue (item_command, "#05"); ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("DELETE", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.DeleteCommand += new DataGridCommandEventHandler (DeleteCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (delete_command, "A6"); Assert.IsTrue (item_command, "#06"); // // Edit // ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("Edit", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.EditCommand += new DataGridCommandEventHandler (EditCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (edit_command, "A7"); Assert.IsTrue (item_command, "#07"); ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("edit", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.EditCommand += new DataGridCommandEventHandler (EditCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (edit_command, "A8"); Assert.IsTrue (item_command, "#08"); ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("EDIT", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.EditCommand += new DataGridCommandEventHandler (EditCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (edit_command, "A9"); Assert.IsTrue (item_command, "#09"); // // Item // ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("Item", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (item_command, "A10"); ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("item", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (item_command, "A11"); ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("ITEM", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (item_command, "A12"); // // Sort // ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("Sort", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.SortCommand += new DataGridSortCommandEventHandler (SortCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (sort_command, "A13"); Assert.IsTrue (item_command, "#10"); ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("sort", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.SortCommand += new DataGridSortCommandEventHandler (SortCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (sort_command, "A14"); Assert.IsTrue (item_command, "#11"); ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("SORT", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.SortCommand += new DataGridSortCommandEventHandler (SortCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (sort_command, "A15"); Assert.IsTrue (item_command, "#12"); // // Update // ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("Update", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.UpdateCommand += new DataGridCommandEventHandler (UpdateCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (update_command, "A16"); Assert.IsTrue (item_command, "#13"); ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("update", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.UpdateCommand += new DataGridCommandEventHandler (UpdateCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (update_command, "A17"); Assert.IsTrue (item_command, "#14"); ResetEvents (); command_args = new DataGridCommandEventArgs (null, null, new CommandEventArgs ("UPDATE", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.UpdateCommand += new DataGridCommandEventHandler (UpdateCommandHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (update_command, "A18"); Assert.IsTrue (item_command, "#15"); // // Select // DataGridItem item = new DataGridItem (0, 0, ListItemType.Item); ResetEvents (); command_args = new DataGridCommandEventArgs (item, null, new CommandEventArgs ("Select", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.SelectedIndexChanged += new EventHandler (SelectedIndexChangedHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (selected_changed, "A19"); Assert.IsTrue (item_command, "#16"); ResetEvents (); command_args = new DataGridCommandEventArgs (item, null, new CommandEventArgs ("select", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.SelectedIndexChanged += new EventHandler (SelectedIndexChangedHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (selected_changed, "A20"); Assert.IsTrue (item_command, "#17"); ResetEvents (); command_args = new DataGridCommandEventArgs (item, null, new CommandEventArgs ("SELECT", String.Empty)); p.ItemCommand += new DataGridCommandEventHandler (ItemCommandHandler); p.SelectedIndexChanged += new EventHandler (SelectedIndexChangedHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (selected_changed, "A21"); Assert.IsTrue (item_command, "#18"); }
protected void ClearColumn(DataGridItem item) { ((DropDownList) item.FindControl("ddlFunction")).SelectedValue = "-1"; ((TextBox) item.FindControl("txtExpression")).Text = ""; ((RadioButtonList) item.FindControl("rblActive")).SelectedValue = "1"; CalendarPopup dtExpression = (CalendarPopup) item.FindControl("dtExpression"); dtExpression.SelectedDate = dtExpression.LowerBoundDate; CalendarPopup dtTo = (CalendarPopup) item.FindControl("dtTo"); dtTo.SelectedDate = dtTo.LowerBoundDate; CalendarPopup dtFrom = (CalendarPopup) item.FindControl("dtFrom"); dtFrom.SelectedDate = dtFrom.LowerBoundDate; ((TextBox) item.FindControl("txtFrom")).Text = ""; ((TextBox) item.FindControl("txtTo")).Text = ""; ((CheckBox) item.FindControl("chkColumnSort")).Checked = false; ((DropDownList) item.FindControl("ddlColumnSortDirection")).SelectedValue = "asc"; }
public void BubblePageCommand () { DataGridPoker p = new DataGridPoker (); DataGridItem item = new DataGridItem (0, 0, ListItemType.Item); DataGridCommandEventArgs command_args; // // Prev // ResetEvents (); command_args = new DataGridCommandEventArgs (item, null, new CommandEventArgs ("Page", "Prev")); p.CurrentPageIndex = 10; p.PageIndexChanged += new DataGridPageChangedEventHandler (PageIndexChangedHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (page_index_changed, "A1"); Assert.AreEqual (new_page_index, 9, "A2"); ResetEvents (); command_args = new DataGridCommandEventArgs (item, null, new CommandEventArgs ("page", "prev")); p.CurrentPageIndex = 10; p.PageIndexChanged += new DataGridPageChangedEventHandler (PageIndexChangedHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (page_index_changed, "A3"); Assert.AreEqual (new_page_index, 9, "A4"); ResetEvents (); command_args = new DataGridCommandEventArgs (item, null, new CommandEventArgs ("PAGE", "PREV")); p.CurrentPageIndex = 10; p.PageIndexChanged += new DataGridPageChangedEventHandler (PageIndexChangedHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (page_index_changed, "A5"); Assert.AreEqual (new_page_index, 9, "A6"); // // Next // ResetEvents (); command_args = new DataGridCommandEventArgs (item, null, new CommandEventArgs ("Page", "Next")); p.CurrentPageIndex = 10; p.PageIndexChanged += new DataGridPageChangedEventHandler (PageIndexChangedHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (page_index_changed, "A5"); Assert.AreEqual (new_page_index, 11, "A6"); ResetEvents (); command_args = new DataGridCommandEventArgs (item, null, new CommandEventArgs ("page", "next")); p.CurrentPageIndex = 10; p.PageIndexChanged += new DataGridPageChangedEventHandler (PageIndexChangedHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (page_index_changed, "A7"); Assert.AreEqual (new_page_index, 11, "A8"); ResetEvents (); command_args = new DataGridCommandEventArgs (item, null, new CommandEventArgs ("PAGE", "NEXT")); p.CurrentPageIndex = 10; p.PageIndexChanged += new DataGridPageChangedEventHandler (PageIndexChangedHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (page_index_changed, "A9"); Assert.AreEqual (new_page_index, 11, "A10"); // // Specific // ResetEvents (); command_args = new DataGridCommandEventArgs (item, null, new CommandEventArgs ("Page", "25")); p.CurrentPageIndex = 10; p.PageIndexChanged += new DataGridPageChangedEventHandler (PageIndexChangedHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (page_index_changed, "A11"); Assert.AreEqual (new_page_index, 24, "A12"); ResetEvents (); command_args = new DataGridCommandEventArgs (item, null, new CommandEventArgs ("Page", "0")); p.CurrentPageIndex = 10; p.PageIndexChanged += new DataGridPageChangedEventHandler (PageIndexChangedHandler); p.DoBubbleEvent (this, command_args); Assert.IsTrue (page_index_changed, "A11"); Assert.AreEqual (new_page_index, -1, "A12"); }
public string GetItemText(DataGridItem item, string cellFieldName) { int cellIndex = this.FindColumnIndex(cellFieldName); return cellIndex>=0?this.GetItemText(item, cellIndex):""; }
public void BadBubblePageArg2 () { DataGridPoker p = new DataGridPoker (); DataGridItem item = new DataGridItem (0, 0, ListItemType.Item); DataGridCommandEventArgs command_args; ResetEvents (); command_args = new DataGridCommandEventArgs (item, null, new CommandEventArgs ("Page", new object ())); p.DoBubbleEvent (this, command_args); }
public void SetItemText(DataGridItem item, string cellFieldName, string text) { int cellIndex = this.FindColumnIndex(cellFieldName); if(cellIndex>=0) this.SetItemText(item, cellIndex, text); }
public DataGridItemEventArgs(DataGridItem item) { }
protected virtual new void InitializePager(DataGridItem item, int columnSpan, PagedDataSource pagedDataSource) { }
private void InitializeNoDataText() { Controls.Clear(); LogWriter.Debug("DataSource is empty. Adding [NoDataText] to control."); Table table = new Table(); Controls.Add(table); // Header row DataGridItem headerRow = new DataGridItem(Items.Count, 0, ListItemType.Header); table.Rows.Add(headerRow); // Header cell headerRow.Cells.Add(new TableCell()); headerRow.Cells[0].Controls.Add(CreateHeaderPanel()); headerRow.CssClass = "Heading2"; // Text cell TableCell textCell = new TableCell(); textCell.Controls.Add(new LiteralControl("<div class='" + NoDataTextCssClass + "' nowrap>" + NoDataText + "</div>")); DataGridItem textRow = new DataGridItem(Items.Count, 0, ListItemType.Item); textRow.Cells.Add(textCell); table.Rows.Add(textRow); }