Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

[4045] Object-Oriented ASP.NET

Last post 12-31-2003 1:13 PM by ASP_Man. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [4045] Object-Oriented ASP.NET

    This thread is for discussions of Object-Oriented ASP.NET.

    • Post Points: 0
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 09-30-2003 11:13 PM In reply to

    • sbguy
    • Not Ranked
    • Joined on 09-30-2003
    • New Member
    • Points 15

    ASP.Net?

    Great article, but am I missing something. I go into Class view, but I get no "Add" option when I right-click on the project. This is an ASP.Net (VB.Net) project, so is it the case that this is not available in ASP.Net projects?
    • Post Points: 0
  • 10-03-2003 11:20 AM In reply to

    • jspadea
    • Not Ranked
    • Joined on 10-03-2003
    • New Member
    • Points 5
    I'm using VB.NET 2003 and I don't see the "Add" option when I right click in the Class view either.
    • Post Points: 0
  • 10-03-2003 1:51 PM In reply to

    Great Article

    great article. I was able to implement the grid in VB.NET quite easily, and I plan on extending it in similar fashion to create DataGrids with selectable rows. Thanks Greg!
    • Post Points: 0
  • 10-03-2003 1:54 PM In reply to

    Getting it to work in VB.NET

    You have to add the class manually as a generic class, then use the Inherits statement

    Public Class DeleteDataGrid ' or whatever you want to call it
       Inherits System.Web.UI.WebControls.DataGrid

    Hitting ENTER after the Inherits statement will make the stubs appear automagically for both CreateControlHierarchy and PrepareControlHierarchy. OnItemDataBound, however, does not show up; you will have to add the function signature yourself.

    HTH

    • Post Points: 0
  • 10-06-2003 6:10 AM In reply to

    Hi Elliot,
    Is there any chance that you can show me the code for the derived datagrid in VB.net.
    Im having trouble creating it myself. Im new to this subclassing stuff.
    Thank you

    Mick Lennon
    Louth
    Ireland
    • Post Points: 0
  • 10-06-2003 7:26 AM In reply to

    Mick:

    shoot me an email at elliotmrodriguezathotmaildotcom and I will send you the class file. Perhaps we can work together on this.

    Oddly enough, when I compile (without errors) and set a reference to the file in my web page, the grid never gets displayed. I've stepped through the code on the webpage that sets its properties, and they work fine; Intellisense shows my properties for the class, so I know its being seen, but none of the events in the class itself get called. I am perplexed.

    Greg Ennis, can you also help?
    • Post Points: 0
  • 12-31-2003 1:13 PM In reply to

    • ASP_Man
    • Not Ranked
    • Joined on 12-31-2003
    • New Member
    • Points 5

    Getting Error Message when running code

    I am getting as error message of

        C:\Program Files\ASP.NET Starter Kits\ASP.NET Portal (CSSDK)\PortalCSSDK\RegDataGrid.cs(20): The type or namespace name 'DataSource' could not be found (are you missing a using directive or an assembly reference?)

        and

        C:\Program Files\ASP.NET Starter Kits\ASP.NET Portal (CSSDK)\PortalCSSDK\RegDataGrid.cs(54): The type or namespace name 'DataGridItemEventArgs' could not be found (are you missing a using directive or an assembly reference?)

    when running the code. What am I missing?

    Here is the code I am running.

    using System;

    namespace ASPNET.StarterKit.Portal
    {
       /// <summary>
       ///
       /// </summary>
       public class RegDataGrid : System.Web.UI.WebControls.DataGrid
       {
           public RegDataGrid()
           {
               //
               // TODO: Add constructor logic here
               //
           }

           // Class member that stores the index of the "Delete" column of this grid
           protected int delcol = -1;

           protected override ArrayList CreateColumnSet(PagedDataSource dataSource, bool useDataSource)
           {
               // Let the DataGrid create the columns
               ArrayList list = base.CreateColumnSet (dataSource, useDataSource);

               // Examine the columns
               delcol=0;
               foreach (DataGridColumn col in list)
               {
                   // If this column is the "Delete" button command column...
                   if ((col is ButtonColumn) && (((ButtonColumn)col).CommandName == "Delete"))
                   {
                       // Found it
                       break;
                   }

                   delcol++;
               }

               // If we did not find a delete column, invalidate the index
               if (delcol == list.Count) delcol = -1;
       
               // Done
               return list;
           }

           // Property to enable/disable deletion confirmation
           protected bool confirmdel = true;
           public bool ConfirmOnDelete
           {
               get { return confirmdel; }
               set { confirmdel = value; }
           }

           protected override void OnItemDataBound(DataGridItemEventArgs e)
           {
               // Create it first in the DataGrid
               base.OnItemDataBound (e);

               // Attach javascript confirmation to the delete button
               if ((confirmdel) && (delcol != -1))
               {
                   e.Item.Cells[delcol].Attributes.Add("onclick", "return confirm('Are you sure?')");
               }
           }
           
       }
    }
    • Post Points: 0
Page 1 of 1 (8 items)