Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to develop a user control?

How to develop a user control?

Scheduled Pinned Locked Moved ASP.NET
tutorialdesignhelpquestionannouncement
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Old Gun
    wrote on last edited by
    #1

    I get a example of FixedDataGrid Written by Alexander Zeitler.His example work well.It is fixed datagrid row height.I want to add some other function to it,such as highlight entire row,The highlight row work well,but the delete ,edit ,update command work failed! the all code is here,Can anyone give some help? using System; using System.IO; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; //using CustomControls; namespace WinDataGrid { public class FixedHeightGrid : System.Web.UI.WebControls.DataGrid { private bool _mergePaddingColumns; private TableItemStyle _paddingItemStyle = new TableItemStyle(); private int _RowHeight = 22; private string _sRowForColor = "white"; private string _sRowBackColor = "lightblue"; public FixedHeightGrid() { this.ShowFooter=false; this.ShowHeader=true; this.AllowPaging=true; } public bool MergePaddingColumns { get {return _mergePaddingColumns;} set {_mergePaddingColumns = value;} } public TableItemStyle PaddingItemStyle { get {return _paddingItemStyle;} set {_paddingItemStyle = value;} } public int RowHeight { get { return _RowHeight;} set {_RowHeight = value;} } public string RowForColor { get { return _sRowForColor;} set {_sRowForColor = value;} } public string RowBackColor { get { return _sRowBackColor;} set {_sRowBackColor = value;} } protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); AddPaddingItems(); } protected override void OnItemCreated(DataGridItemEventArgs e) { base.OnItemCreated(e); if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { e.Item.Attributes.Add("OnMouseOver", "this.style.backgroundColor = '" + _sRowBackColor + "';"); e.Item.Attributes.Add("OnMouseOut", "this.style.backgroundColor = '" + _sRowForColor + "';"); } } private void AddPaddingItems() { int indexCount; int indexStop = this.PageSize; int indexStart = 1; if(this.AllowPaging==true) { indexStart++; indexStop++; } Table myTable = (Table)this.Controls[0]; for(indexCount=indexStart+this.Items.Count;indexCount<=indexStop;indexCount++) { myTable.Controls.AddAt(indexCount,PaddingItem()); } } private DataGridItem PaddingItem() { DataGridItem myItem = new DataGridItem(0,0,ListItemType.Item)

    E 1 Reply Last reply
    0
    • O Old Gun

      I get a example of FixedDataGrid Written by Alexander Zeitler.His example work well.It is fixed datagrid row height.I want to add some other function to it,such as highlight entire row,The highlight row work well,but the delete ,edit ,update command work failed! the all code is here,Can anyone give some help? using System; using System.IO; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; //using CustomControls; namespace WinDataGrid { public class FixedHeightGrid : System.Web.UI.WebControls.DataGrid { private bool _mergePaddingColumns; private TableItemStyle _paddingItemStyle = new TableItemStyle(); private int _RowHeight = 22; private string _sRowForColor = "white"; private string _sRowBackColor = "lightblue"; public FixedHeightGrid() { this.ShowFooter=false; this.ShowHeader=true; this.AllowPaging=true; } public bool MergePaddingColumns { get {return _mergePaddingColumns;} set {_mergePaddingColumns = value;} } public TableItemStyle PaddingItemStyle { get {return _paddingItemStyle;} set {_paddingItemStyle = value;} } public int RowHeight { get { return _RowHeight;} set {_RowHeight = value;} } public string RowForColor { get { return _sRowForColor;} set {_sRowForColor = value;} } public string RowBackColor { get { return _sRowBackColor;} set {_sRowBackColor = value;} } protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); AddPaddingItems(); } protected override void OnItemCreated(DataGridItemEventArgs e) { base.OnItemCreated(e); if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { e.Item.Attributes.Add("OnMouseOver", "this.style.backgroundColor = '" + _sRowBackColor + "';"); e.Item.Attributes.Add("OnMouseOut", "this.style.backgroundColor = '" + _sRowForColor + "';"); } } private void AddPaddingItems() { int indexCount; int indexStop = this.PageSize; int indexStart = 1; if(this.AllowPaging==true) { indexStart++; indexStop++; } Table myTable = (Table)this.Controls[0]; for(indexCount=indexStart+this.Items.Count;indexCount<=indexStop;indexCount++) { myTable.Controls.AddAt(indexCount,PaddingItem()); } } private DataGridItem PaddingItem() { DataGridItem myItem = new DataGridItem(0,0,ListItemType.Item)

      E Offline
      E Offline
      ednrgc
      wrote on last edited by
      #2

      You need to check out Event Bubbling: http://www.odetocode.com/Articles/94.aspx

      O 3 Replies Last reply
      0
      • E ednrgc

        You need to check out Event Bubbling: http://www.odetocode.com/Articles/94.aspx

        O Offline
        O Offline
        Old Gun
        wrote on last edited by
        #3

        Thank you!I'll try it.

        1 Reply Last reply
        0
        • E ednrgc

          You need to check out Event Bubbling: http://www.odetocode.com/Articles/94.aspx

          O Offline
          O Offline
          Old Gun
          wrote on last edited by
          #4

          Hi,edboe I read your tips,but I can't understand it well. Can you give me more tips why FixedDataGrid is not work? thanks

          1 Reply Last reply
          0
          • E ednrgc

            You need to check out Event Bubbling: http://www.odetocode.com/Articles/94.aspx

            O Offline
            O Offline
            Old Gun
            wrote on last edited by
            #5

            Hi,edboe I read your tips,but I can't understand it well. Can you give me more tips why FixedDataGrid's DeleteCommand,EditCommand,InsertCommand,UpdateCommand and CancelCommand is not work? thanks

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups