public void SpecialLinkButton2 () { DataTable dt = new DataTable(); dt.Columns.Add (new DataColumn("string_col", typeof(string))); DataRow dr = dt.NewRow (); dt.Rows.Add (new object [] { "Item 1" }); DataView dv = new DataView (dt); DataGridPoker dg = new DataGridPoker (); dg.DataSource = dv; dg.AutoGenerateColumns = false; dg.HeaderStyle.ForeColor = Color.FromArgb (255,255,255,255); dg.HeaderStyle.BackColor = Color.FromArgb (33,33,33,33); ButtonColumn bc = new ButtonColumn (); bc.HeaderText = "Some header"; bc.DataTextField = "string_col"; bc.CommandName = "lalala"; dg.Columns.Add (bc); BoundColumn bound = new BoundColumn (); bound.HeaderText = "The other column"; bound.DataField = "string_col"; dg.Columns.Add (bound); dg.DataBind (); LinkButton lb = (LinkButton) FindByType (dg.Controls [0], typeof (LinkButton)); Assert.IsNotNull (lb, "lb"); StringWriter sr = new StringWriter (); HtmlTextWriter output = new HtmlTextWriter (sr); Assert.AreEqual (Color.Empty, lb.ControlStyle.ForeColor, "fore"); lb.RenderControl (output); Assert.AreEqual (Color.Empty, lb.ControlStyle.ForeColor, "fore2"); string str = dg.Render (); Assert.IsTrue (-1 != str.IndexOf ("<a>Item 1</a>"), "item1"); Assert.IsTrue (-1 != str.IndexOf ("<td>Item 1</td>"), "item1-2"); }
public void SpecialLinkButton1 () { DataTable dt = new DataTable(); dt.Columns.Add (new DataColumn("something", typeof(Int32))); DataRow dr = dt.NewRow (); dt.Rows.Add (new object [] { 1 }); DataView dv = new DataView (dt); DataGridPoker dg = new DataGridPoker (); dg.AllowSorting = true; dg.HeaderStyle.Font.Bold = true; dg.HeaderStyle.ForeColor = Color.FromArgb (255,255,255,255); dg.HeaderStyle.BackColor = Color.FromArgb (33,33,33,33); dg.DataSource = dv; dg.DataBind (); LinkButton lb = (LinkButton) FindByType (dg.Controls [0], typeof (LinkButton)); Assert.IsNotNull (lb, "lb"); StringWriter sr = new StringWriter (); HtmlTextWriter output = new HtmlTextWriter (sr); // Nothing here... Assert.AreEqual (Color.Empty, lb.ControlStyle.ForeColor, "fore"); lb.RenderControl (output); // Nothing here... Assert.AreEqual (Color.Empty, lb.ControlStyle.ForeColor, "fore2"); dg.Render (); // Surprise! after rendering the datagrid, the linkbutton has the ForeColor from the datagrid Assert.AreEqual (Color.FromArgb (255,255,255,255), lb.ControlStyle.ForeColor, "fore3"); // Extra. Items != empty Assert.AreEqual (1, dg.Items.Count, "itemCount"); }
public void OneTemplateColumn3 () { DataGridPoker p = new DataGridPoker (); p.ShowFooter = true; p.AutoGenerateColumns = false; p.DataSource = new ArrayList (); TemplateColumn tc = new TemplateColumn (); tc.FooterTemplate = new MyTemplate ("hola"); p.Columns.Add (tc); p.DataBind (); StringWriter sw = new StringWriter (); HtmlTextWriter tw = new HtmlTextWriter (sw); Assert.AreEqual (1, p.Columns.Count, "columns"); Assert.AreEqual (1, p.Controls.Count, "controls"); string render = p.Render (); // no items, but we have a footer Assert.IsTrue (-1 != render.IndexOf ("hola"), "template"); }
public void Render () { DataGridPoker p = new DataGridPoker (); Assert.AreEqual (p.Render (), String.Empty, "A1"); }
public void OneTemplateColumn1 () { DataGridPoker p = new DataGridPoker (); TemplateColumn tc = new TemplateColumn (); tc.ItemTemplate = new MyTemplate ("hola"); p.Columns.Add (tc); ControlCollection controls = p.Controls; p.CreateControls (true); Assert.AreEqual (1, p.Columns.Count, "columns"); Assert.AreEqual (0, controls.Count, "controls"); string render = p.Render (); // no items, even with a templated column. // The table is not added if DataSource == null Assert.IsTrue (-1 == render.IndexOf ("hola"), "template"); }