Datagrid- adding/editing record with a column that uses a drop dow

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

ADO.NET Datagrid do NOT provide native support for
1) Adding records
2) Using Drop-down lists in editing a column

However,
1) http://aspnet.4guysfromrolla.com/articles/021203-1.aspx provides an
excellent guide on how to add records using template columns (textboxes, etc.
at the footer, and implementing the OnItemCommand event handler)
2)
http://msdn.microsoft.com/library/e...s.asp?frame=true#creatingcustomcolumns_topic6
provides an equally excellent article on how to use a drop down column

However, I can I combine the two together such that
1) In Normal view (when not editing), all data appears as plain-text
2) When Edit button/link is clicked, the column specified to use
DropDownColumn appears as a drop-down list
3) At the footer, a drop-down list of DropDownColumn type is used.
 
I tried adding the following to The DataGridColumn class:
'Case ListItemType.Footer
' AddHandler cell.DataBinding, AddressOf
EditItemDataBinding
' Dim DDL As New DropDownList
' DDL.ID = "add" + DataField
' cell.Controls.Add(DDL)

but when the page loads and following hitting these few lines
EditItemDataBinding is hit, I get a null exception on For Each DataSourceItem
In DataSource, as DataSource had only been initialised at protected void
UsersDataGrid_Edit(Object sender, DataGridCommandEventArgs e) , which is good
enough for data editing, but not for the Footer, how/where could I initialise
the DataSource for the footer?
 
Hi Patrick,

Welcome to MSDN newsgroup.
As for the Custom DropDownColumn in the below tech article:

http://msdn.microsoft.com/library/en-us/dnaspp/html/creatingcustomcolumns.as
p?frame=true#creatingcustomcolumns_topic6

it's "DataSource" property is used to populate the DropDownList, as you
mentioend that if you set the datasource at
DataGrid_Edit event handler, it's ok for bind items to the dropdownlist
in Edit template. However, since the DropDownList in the Footer template
need to be bind everytime no matter the edit event is fired or not, wo
should assign the DataSource in another place which will be executed
everytime. I think Page's Init or Load event is a proper place, we can
just find the DropDownColumn from the DataGrid's Columns collection and
assign the datasource for it.

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- adding/editing record with a column that uses a
drop dow
| thread-index: AcWihKn30embLAEfQd2071TaNMDU6g==
| X-WBNR-Posting-Host: 198.240.128.75
| From: "=?Utf-8?B?UGF0cmljaw==?=" <[email protected]>
| References: <[email protected]>
| Subject: RE: Datagrid- adding/editing record with a column that uses a
drop dow
| Date: Tue, 16 Aug 2005 10:05:12 -0700
| Lines: 35
| 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.adonet
| 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.adonet:34112
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| I tried adding the following to The DataGridColumn class:
| 'Case ListItemType.Footer
| ' AddHandler cell.DataBinding, AddressOf
| EditItemDataBinding
| ' Dim DDL As New DropDownList
| ' DDL.ID = "add" + DataField
| ' cell.Controls.Add(DDL)
|
| but when the page loads and following hitting these few lines
| EditItemDataBinding is hit, I get a null exception on For Each
DataSourceItem
| In DataSource, as DataSource had only been initialised at protected void
| UsersDataGrid_Edit(Object sender, DataGridCommandEventArgs e) , which is
good
| enough for data editing, but not for the Footer, how/where could I
initialise
| the DataSource for the footer?
|
| "Patrick" wrote:
|
| > ADO.NET Datagrid do NOT provide native support for
| > 1) Adding records
| > 2) Using Drop-down lists in editing a column
| >
| > However,
| > 1) http://aspnet.4guysfromrolla.com/articles/021203-1.aspx provides an
| > excellent guide on how to add records using template columns
(textboxes, etc.
| > at the footer, and implementing the OnItemCommand event handler)
| > 2)
| >
http://msdn.microsoft.com/library/en-us/dnaspp/html/creatingcustomcolumns.as
p?frame=true#creatingcustomcolumns_topic6
| > provides an equally excellent article on how to use a drop down column
| >
| > However, I can I combine the two together such that
| > 1) In Normal view (when not editing), all data appears as plain-text
| > 2) When Edit button/link is clicked, the column specified to use
| > DropDownColumn appears as a drop-down list
| > 3) At the footer, a drop-down list of DropDownColumn type is used.
| >
|
 
Hi Patrick,

Have you got a chance to view the suggestions in my last reply or have you
got any further progress on this issue? If there're anything else we 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.)


--------------------
| X-Tomcat-ID: 62051915
| References: <[email protected]>
<[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: (e-mail address removed) (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Wed, 17 Aug 2005 03:20:57 GMT
| Subject: RE: Datagrid- adding/editing record with a column that uses a
drop dow
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Lines: 99
| Path: TK2MSFTNGXA01.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl microsoft.public.dotnet.framework.adonet:34164
| NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
|
| Hi Patrick,
|
| Welcome to MSDN newsgroup.
| As for the Custom DropDownColumn in the below tech article:
|
|
http://msdn.microsoft.com/library/en-us/dnaspp/html/creatingcustomcolumns.as
| p?frame=true#creatingcustomcolumns_topic6
|
| it's "DataSource" property is used to populate the DropDownList, as you
| mentioend that if you set the datasource at
| DataGrid_Edit event handler, it's ok for bind items to the dropdownlist
| in Edit template. However, since the DropDownList in the Footer template
| need to be bind everytime no matter the edit event is fired or not, wo
| should assign the DataSource in another place which will be executed
| everytime. I think Page's Init or Load event is a proper place, we can
| just find the DropDownColumn from the DataGrid's Columns collection and
| assign the datasource for it.
|
| 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- adding/editing record with a column that uses a
| drop dow
| | thread-index: AcWihKn30embLAEfQd2071TaNMDU6g==
| | X-WBNR-Posting-Host: 198.240.128.75
| | From: "=?Utf-8?B?UGF0cmljaw==?=" <[email protected]>
| | References: <[email protected]>
| | Subject: RE: Datagrid- adding/editing record with a column that uses a
| drop dow
| | Date: Tue, 16 Aug 2005 10:05:12 -0700
| | Lines: 35
| | 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.adonet
| | 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.adonet:34112
| | X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
| |
| | I tried adding the following to The DataGridColumn class:
| | 'Case ListItemType.Footer
| | ' AddHandler cell.DataBinding, AddressOf
| | EditItemDataBinding
| | ' Dim DDL As New DropDownList
| | ' DDL.ID = "add" + DataField
| | ' cell.Controls.Add(DDL)
| |
| | but when the page loads and following hitting these few lines
| | EditItemDataBinding is hit, I get a null exception on For Each
| DataSourceItem
| | In DataSource, as DataSource had only been initialised at protected
void
| | UsersDataGrid_Edit(Object sender, DataGridCommandEventArgs e) , which
is
| good
| | enough for data editing, but not for the Footer, how/where could I
| initialise
| | the DataSource for the footer?
| |
| | "Patrick" wrote:
| |
| | > ADO.NET Datagrid do NOT provide native support for
| | > 1) Adding records
| | > 2) Using Drop-down lists in editing a column
| | >
| | > However,
| | > 1) http://aspnet.4guysfromrolla.com/articles/021203-1.aspx provides
an
| | > excellent guide on how to add records using template columns
| (textboxes, etc.
| | > at the footer, and implementing the OnItemCommand event handler)
| | > 2)
| | >
|
http://msdn.microsoft.com/library/en-us/dnaspp/html/creatingcustomcolumns.as
| p?frame=true#creatingcustomcolumns_topic6
| | > provides an equally excellent article on how to use a drop down column
| | >
| | > However, I can I combine the two together such that
| | > 1) In Normal view (when not editing), all data appears as plain-text
| | > 2) When Edit button/link is clicked, the column specified to use
| | > DropDownColumn appears as a drop-down list
| | > 3) At the footer, a drop-down list of DropDownColumn type is used.
| | >
| |
|
|
 
Back
Top