Hi Terry,
I've managed to got both this one and your new post. I've posted my reply
your new thread. I think we can continue to discuss in that one. Please
feel free to post there. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: DataGrid
| thread-index: AcWczSl+CneD7ielQ4uXPsua4furrg==
| X-WBNR-Posting-Host: 194.200.135.240
| From: "=?Utf-8?B?VGVycnkgSG9sbGFuZA==?="
<
[email protected]>
| References: <#
[email protected]>
<
[email protected]>
<
[email protected]>
<
[email protected]>
| Subject: RE: DataGrid
| Date: Tue, 9 Aug 2005 03:29:02 -0700
| Lines: 176
| Message-ID: <
[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:10358
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Steven
|
| Thank you. I mangaged to get your sample code working. However I am
having
| difficulty getting the code in the article
| #Creating Custom Columns for the ASP.NET Datagrid
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html
| /creatingcustomcolumns.asp
|
| I am able to get the example that you can download working but am unable
to
| get it working in an application of my own.
|
| I get the following error which occurrs on the line
| cell.text = dgi.DataItem(DataField)
|
| error
| =============
| Line 34: Throw New Exception(ex.InnerException.ToString)
| Line 35: End Try
| Line 36: End Sub
|
|
| Source File:
C:\_Development\CSA\Dev\ControlExtenders\clsDropDownColumn.vb
| Line: 34
|
| Stack Trace:
|
|
| [NullReferenceException: Object reference not set to an instance of an
| object.]
|
| =============
|
| Any ideas why this is happening?
|
| Also, is it possible for me to add a customcolumn completely
| programmatically (ie without the need to add a @register directive and a
| <ddg
ropDownColumn .../> tag on my page?
|
| thanks in advance
|
|
|
|
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi Terry,
| >
| > Thanks for the response. Here is my complete testcode:
| >
| > #complete custom column class
| > ========================
| > Public Class ColumnClass
| > Inherits System.Web.UI.WebControls.DataGridColumn
| >
| > Public Overrides Sub InitializeCell(ByVal cell As TableCell, ByVal
| > columnIndex As Integer, ByVal itemType As ListItemType)
| > MyBase.InitializeCell(cell, columnIndex, itemType)
| > If ((itemType <> ListItemType.Header) And (itemType <>
| > ListItemType.Footer)) Then
| >
| > Dim control1 As WebControl = Nothing
| >
| > Dim imgbtn = New System.Web.UI.WebControls.ImageButton
| >
| >
| > imgbtn.ImageUrl =
| >
"
http://msdn.microsoft.com/library/toolbar/3.0/images/banners/msdn_masthead_
| > ltr.gif"
| >
| > imgbtn.CommandName = "Edit"
| >
| > control1 = imgbtn
| >
| > cell.Controls.Add(control1)
| > End If
| > End Sub
| >
| >
| >
| > End Class
| > ===================
| >
| > #the code in my page which contains the datagrid:
| >
| > =============here i dynamically add my custom datagrid column into the
| > grid=========
| > Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
| > System.EventArgs) Handles MyBase.Init
| > InitializeComponent()
| >
| > Dim cc As New ColumnClass
| >
| > dgDynamic.Columns.Add(cc)
| >
| >
| > .......... other dynamic code
| >
| > End Sub
| >
| > ====================
| >
| > I there're anything else unclear or I can help ,please feel free to
post
| > here.
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure!
www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| > --------------------
| > | Thread-Topic: DataGrid
| > | thread-index: AcWb/jdG3dDvBk8USJKBuQOij5EFWQ==
| > | X-WBNR-Posting-Host: 194.200.135.240
| > | From: "=?Utf-8?B?VGVycnkgSG9sbGFuZA==?="
| > <
[email protected]>
| > | References: <#
[email protected]>
| > <
[email protected]>
| > | Subject: RE: DataGrid
| > | Date: Mon, 8 Aug 2005 02:47:41 -0700
| > | Lines: 28
| > | Message-ID: <
[email protected]>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.webcontrols:10328
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| > |
| > | Thank you Steven
| > |
| > | Im not entirely sure what to do with code that you included in your
| > reply.
| > | I have tried the following
| > |
| > | Created a new user control that inherits
| > | System.Web.UI.WebControls.DataGridColumn and then paste in the
| > | Public Overrides Sub InitializeCell(ByVal cell As TableCell, ByVal
| > | columnIndex As
| > | Integer, ByVal
| > itemType
| > | As ListItemType)
| > | method that you included in your posting.
| > |
| > | When i try to compile I get an error " Event 'Init' cannot be found."
| > | on the event in my new ImageButonColumn control.
| > |
| > | Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
| > | System.EventArgs) Handles MyBase.Init
| > | 'CODEGEN: This method call is required by the Web Form
Designer
| > | 'Do not modify it using the code editor.
| > | InitializeComponent()
| > | End Sub
| > |
| > | If I delete this event then app compiles but Im a bit worried Im
doing
| > the
| > | wrong thing
| > |
| > |
| > | Terry
| > |
| >
| >
|