469,358 Members | 1,659 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,358 developers. It's quick & easy.

DataItem in DataListItem is null.

Hello,

the problem I have now, is:

Im binding generic collection based on List<iDB2SQLTransferItem> //
iDB2SQLTransferItem is my class // into WebCOntrol DataList. But the
DataItem of the DataListCommandEventArgs is null. Here is my code:

private MyData.iDB2SQLTransfers transfers = null;

protected void Page_Load(object sender, EventArgs e)
{
AppSettingsReader apReader = new AppSettingsReader();
string dtdPath = (string)apReader.GetValue("DTDPath", typeof(string));
transfers = iDB2SQLTransfers.Load(dtdPath);
this.dlDTDefinitions.DataSource = transfers;
this.dlDTDefinitions.DataBind();
}

protected void dlDTDefinitions_ItemCommand(object source,
DataListCommandEventArgs e)
{
switch(e.CommandName)
{

case "Save":
// Here i suppose, that in the DataItem is edited item typeof
iDB2SQLTransferItem
// but it is null. (ListItemType is right - EditItem)
iDB2SQLTransferItem item = (iDB2SQLTransferItem)e.Item.DataItem
dlDTDefinitions.EditItemIndex = -1;
dlDTDefinitions.SelectedIndex = e.Item.ItemIndex;
break;
}

---------------------------------------------
Code in aspx page // Only EditItemTemplate //
---------------------------------------------

<EditItemTemplate>
<table>
<tr>
<td>ID:</td>
<td nowrap="nowrap" valign="top"><%#
DataBinder.Eval(Container.DataItem, "ID")%></td>
<td>Caption:</td>
<td>
<asp:TextBox ID="txtCaption" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Caption") %>'></asp:TextBox></td>
<td>Description:</td>
<td>
<asp:TextBox ID="txtDescription" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>'
</asp:TextBox></td>

</tr>
</table>

==================================================

All is working well, data are viewed, commands are working well, but on Save
command I need to get edited iDB2SQLTransferItem and save it.

Thanks for ideas.

Mirek
Nov 21 '05 #1
7 2089
Hi Mirek,

Welcome to ASPNET newsgroup.
Regarding on the DataList databinding with Generic List instance problem, I
think we should use the DataList's "ItemDataBound" event instead of the
"ItemCommand" event. The "Itemcommand" event is used for processing
DataList's Postback events , such as "Edit", "update".... If we need to
programmatically access the current bound datasource's dataitems and do
customization on the DataList's inner Control with the DataItem, we should
use the "ItemDataBound" event , this event will be fired when each DataItem
has been bound to the DataList's certain Row.....

If there're anything else unclear, 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.)


--------------------
| From: "Mirek Endys" <Mi****@community.nospam>
| Subject: DataItem in DataListItem is null.
| Date: Mon, 21 Nov 2005 10:01:33 +0100
| Lines: 67
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| Message-ID: <e6**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups:
microsoft.public.dotnet.framework.aspnet,microsoft .public.dotnet.framework.a
spnet.webcontrols
| NNTP-Posting-Host: gw.coty.cz 195.47.52.129
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontro ls:31227
microsoft.public.dotnet.framework.aspnet:359739
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hello,
|
| the problem I have now, is:
|
| Im binding generic collection based on List<iDB2SQLTransferItem> //
| iDB2SQLTransferItem is my class // into WebCOntrol DataList. But the
| DataItem of the DataListCommandEventArgs is null. Here is my code:
|
| private MyData.iDB2SQLTransfers transfers = null;
|
| protected void Page_Load(object sender, EventArgs e)
| {
| AppSettingsReader apReader = new AppSettingsReader();
| string dtdPath = (string)apReader.GetValue("DTDPath", typeof(string));
| transfers = iDB2SQLTransfers.Load(dtdPath);
| this.dlDTDefinitions.DataSource = transfers;
| this.dlDTDefinitions.DataBind();
| }
|
| protected void dlDTDefinitions_ItemCommand(object source,
| DataListCommandEventArgs e)
| {
| switch(e.CommandName)
| {
|
| case "Save":
| // Here i suppose, that in the DataItem is edited item typeof
| iDB2SQLTransferItem
| // but it is null. (ListItemType is right - EditItem)
| iDB2SQLTransferItem item =
(iDB2SQLTransferItem)e.Item.DataItem
| dlDTDefinitions.EditItemIndex = -1;
| dlDTDefinitions.SelectedIndex = e.Item.ItemIndex;
| break;
| }
|
| ---------------------------------------------
| Code in aspx page // Only EditItemTemplate //
| ---------------------------------------------
|
| <EditItemTemplate>
| <table>
| <tr>
| <td>ID:</td>
| <td nowrap="nowrap" valign="top"><%#
| DataBinder.Eval(Container.DataItem, "ID")%></td>
| <td>Caption:</td>
| <td>
| <asp:TextBox ID="txtCaption" runat="server" Text='<%#
| DataBinder.Eval(Container.DataItem, "Caption") %>'></asp:TextBox></td>
| <td>Description:</td>
| <td>
| <asp:TextBox ID="txtDescription" runat="server"
| Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>'
| ></asp:TextBox></td>
| </tr>
| </table>
|
| ==================================================
|
| All is working well, data are viewed, commands are working well, but on
Save
| command I need to get edited iDB2SQLTransferItem and save it.
|
| Thanks for ideas.
|
| Mirek
|
|
|

Nov 23 '05 #2
Hi Mirek,

How are you doing on this issue , does the suggestion in my last reply
helps a little?
If threre'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: 27416236
| References: <e6**************@TK2MSFTNGP12.phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: st*****@online.microsoft.com (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Tue, 22 Nov 2005 01:24:42 GMT
| Subject: RE: DataItem in DataListItem is null.
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| Message-ID: <HU**************@TK2MSFTNGXA02.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Lines: 102
| Path: TK2MSFTNGXA02.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:360011
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| Hi Mirek,
|
| Welcome to ASPNET newsgroup.
| Regarding on the DataList databinding with Generic List instance problem,
I
| think we should use the DataList's "ItemDataBound" event instead of the
| "ItemCommand" event. The "Itemcommand" event is used for processing
| DataList's Postback events , such as "Edit", "update".... If we need to
| programmatically access the current bound datasource's dataitems and do
| customization on the DataList's inner Control with the DataItem, we
should
| use the "ItemDataBound" event , this event will be fired when each
DataItem
| has been bound to the DataList's certain Row.....
|
| If there're anything else unclear, 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.)
|
|
|
|
| --------------------
| | From: "Mirek Endys" <Mi****@community.nospam>
| | Subject: DataItem in DataListItem is null.
| | Date: Mon, 21 Nov 2005 10:01:33 +0100
| | Lines: 67
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| | X-RFC2646: Format=Flowed; Original
| | Message-ID: <e6**************@TK2MSFTNGP12.phx.gbl>
| | Newsgroups:
|
microsoft.public.dotnet.framework.aspnet,microsoft .public.dotnet.framework.a
| spnet.webcontrols
| | NNTP-Posting-Host: gw.coty.cz 195.47.52.129
| | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| | Xref: TK2MSFTNGXA02.phx.gbl
| microsoft.public.dotnet.framework.aspnet.webcontro ls:31227
| microsoft.public.dotnet.framework.aspnet:359739
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| |
| | Hello,
| |
| | the problem I have now, is:
| |
| | Im binding generic collection based on List<iDB2SQLTransferItem> //
| | iDB2SQLTransferItem is my class // into WebCOntrol DataList. But the
| | DataItem of the DataListCommandEventArgs is null. Here is my code:
| |
| | private MyData.iDB2SQLTransfers transfers = null;
| |
| | protected void Page_Load(object sender, EventArgs e)
| | {
| | AppSettingsReader apReader = new AppSettingsReader();
| | string dtdPath = (string)apReader.GetValue("DTDPath",
typeof(string));
| | transfers = iDB2SQLTransfers.Load(dtdPath);
| | this.dlDTDefinitions.DataSource = transfers;
| | this.dlDTDefinitions.DataBind();
| | }
| |
| | protected void dlDTDefinitions_ItemCommand(object source,
| | DataListCommandEventArgs e)
| | {
| | switch(e.CommandName)
| | {
| |
| | case "Save":
| | // Here i suppose, that in the DataItem is edited item
typeof
| | iDB2SQLTransferItem
| | // but it is null. (ListItemType is right - EditItem)
| | iDB2SQLTransferItem item =
| (iDB2SQLTransferItem)e.Item.DataItem
| | dlDTDefinitions.EditItemIndex = -1;
| | dlDTDefinitions.SelectedIndex = e.Item.ItemIndex;
| | break;
| | }
| |
| | ---------------------------------------------
| | Code in aspx page // Only EditItemTemplate //
| | ---------------------------------------------
| |
| | <EditItemTemplate>
| | <table>
| | <tr>
| | <td>ID:</td>
| | <td nowrap="nowrap" valign="top"><%#
| | DataBinder.Eval(Container.DataItem, "ID")%></td>
| | <td>Caption:</td>
| | <td>
| | <asp:TextBox ID="txtCaption" runat="server" Text='<%#
| | DataBinder.Eval(Container.DataItem, "Caption") %>'></asp:TextBox></td>
| | <td>Description:</td>
| | <td>
| | <asp:TextBox ID="txtDescription" runat="server"
| | Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>'
| | ></asp:TextBox></td>
| | </tr>
| | </table>
| |
| | ==================================================
| |
| | All is working well, data are viewed, commands are working well, but on
| Save
| | command I need to get edited iDB2SQLTransferItem and save it.
| |
| | Thanks for ideas.
| |
| | Mirek
| |
| |
| |
|
|

Nov 24 '05 #3
Thanks, it works well.
"Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
news:M$**************@TK2MSFTNGXA02.phx.gbl...
Hi Mirek,

How are you doing on this issue , does the suggestion in my last reply
helps a little?
If threre'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: 27416236
| References: <e6**************@TK2MSFTNGP12.phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: st*****@online.microsoft.com (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Tue, 22 Nov 2005 01:24:42 GMT
| Subject: RE: DataItem in DataListItem is null.
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| Message-ID: <HU**************@TK2MSFTNGXA02.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Lines: 102
| Path: TK2MSFTNGXA02.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:360011
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| Hi Mirek,
|
| Welcome to ASPNET newsgroup.
| Regarding on the DataList databinding with Generic List instance
problem,
I
| think we should use the DataList's "ItemDataBound" event instead of the
| "ItemCommand" event. The "Itemcommand" event is used for processing
| DataList's Postback events , such as "Edit", "update".... If we need
to
| programmatically access the current bound datasource's dataitems and do
| customization on the DataList's inner Control with the DataItem, we
should
| use the "ItemDataBound" event , this event will be fired when each
DataItem
| has been bound to the DataList's certain Row.....
|
| If there're anything else unclear, 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.)
|
|
|
|
| --------------------
| | From: "Mirek Endys" <Mi****@community.nospam>
| | Subject: DataItem in DataListItem is null.
| | Date: Mon, 21 Nov 2005 10:01:33 +0100
| | Lines: 67
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| | X-RFC2646: Format=Flowed; Original
| | Message-ID: <e6**************@TK2MSFTNGP12.phx.gbl>
| | Newsgroups:
|
microsoft.public.dotnet.framework.aspnet,microsoft .public.dotnet.framework.a
| spnet.webcontrols
| | NNTP-Posting-Host: gw.coty.cz 195.47.52.129
| | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| | Xref: TK2MSFTNGXA02.phx.gbl
| microsoft.public.dotnet.framework.aspnet.webcontro ls:31227
| microsoft.public.dotnet.framework.aspnet:359739
| | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| |
| | Hello,
| |
| | the problem I have now, is:
| |
| | Im binding generic collection based on List<iDB2SQLTransferItem> //
| | iDB2SQLTransferItem is my class // into WebCOntrol DataList. But the
| | DataItem of the DataListCommandEventArgs is null. Here is my code:
| |
| | private MyData.iDB2SQLTransfers transfers = null;
| |
| | protected void Page_Load(object sender, EventArgs e)
| | {
| | AppSettingsReader apReader = new AppSettingsReader();
| | string dtdPath = (string)apReader.GetValue("DTDPath",
typeof(string));
| | transfers = iDB2SQLTransfers.Load(dtdPath);
| | this.dlDTDefinitions.DataSource = transfers;
| | this.dlDTDefinitions.DataBind();
| | }
| |
| | protected void dlDTDefinitions_ItemCommand(object source,
| | DataListCommandEventArgs e)
| | {
| | switch(e.CommandName)
| | {
| |
| | case "Save":
| | // Here i suppose, that in the DataItem is edited item
typeof
| | iDB2SQLTransferItem
| | // but it is null. (ListItemType is right - EditItem)
| | iDB2SQLTransferItem item =
| (iDB2SQLTransferItem)e.Item.DataItem
| | dlDTDefinitions.EditItemIndex = -1;
| | dlDTDefinitions.SelectedIndex = e.Item.ItemIndex;
| | break;
| | }
| |
| | ---------------------------------------------
| | Code in aspx page // Only EditItemTemplate //
| | ---------------------------------------------
| |
| | <EditItemTemplate>
| | <table>
| | <tr>
| | <td>ID:</td>
| | <td nowrap="nowrap" valign="top"><%#
| | DataBinder.Eval(Container.DataItem, "ID")%></td>
| | <td>Caption:</td>
| | <td>
| | <asp:TextBox ID="txtCaption" runat="server" Text='<%#
| | DataBinder.Eval(Container.DataItem, "Caption") %>'></asp:TextBox></td>
| | <td>Description:</td>
| | <td>
| | <asp:TextBox ID="txtDescription" runat="server"
| | Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>'
| | ></asp:TextBox></td>
| | </tr>
| | </table>
| |
| | ==================================================
| |
| | All is working well, data are viewed, commands are working well, but
on
| Save
| | command I need to get edited iDB2SQLTransferItem and save it.
| |
| | Thanks for ideas.
| |
| | Mirek
| |
| |
| |
|
|

Nov 25 '05 #4
You're welcome Mirek,

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Mirek Endys" <Mi****@community.nospam>
| References: <e6**************@TK2MSFTNGP12.phx.gbl>
<HU**************@TK2MSFTNGXA02.phx.gbl>
<M$**************@TK2MSFTNGXA02.phx.gbl>
| Subject: Re: DataItem in DataListItem is null.
| Date: Fri, 25 Nov 2005 13:33:56 +0100
| Lines: 170
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-RFC2646: Format=Flowed; Original
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <O8**************@TK2MSFTNGP12.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: gw.coty.cz 195.47.52.129
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:360889
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Thanks, it works well.
|
|
| "Steven Cheng[MSFT]" <st*****@online.microsoft.com> wrote in message
| news:M$**************@TK2MSFTNGXA02.phx.gbl...
| > Hi Mirek,
| >
| > How are you doing on this issue , does the suggestion in my last reply
| > helps a little?
| > If threre'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: 27416236
| > | References: <e6**************@TK2MSFTNGP12.phx.gbl>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain
| > | Content-Transfer-Encoding: 7bit
| > | From: st*****@online.microsoft.com (Steven Cheng[MSFT])
| > | Organization: Microsoft
| > | Date: Tue, 22 Nov 2005 01:24:42 GMT
| > | Subject: RE: DataItem in DataListItem is null.
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > | Message-ID: <HU**************@TK2MSFTNGXA02.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | Lines: 102
| > | Path: TK2MSFTNGXA02.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:360011
| > | NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
| > |
| > | Hi Mirek,
| > |
| > | Welcome to ASPNET newsgroup.
| > | Regarding on the DataList databinding with Generic List instance
| > problem,
| > I
| > | think we should use the DataList's "ItemDataBound" event instead of
the
| > | "ItemCommand" event. The "Itemcommand" event is used for processing
| > | DataList's Postback events , such as "Edit", "update".... If we
need
| > to
| > | programmatically access the current bound datasource's dataitems and
do
| > | customization on the DataList's inner Control with the DataItem, we
| > should
| > | use the "ItemDataBound" event , this event will be fired when each
| > DataItem
| > | has been bound to the DataList's certain Row.....
| > |
| > | If there're anything else unclear, 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.)
| > |
| > |
| > |
| > |
| > | --------------------
| > | | From: "Mirek Endys" <Mi****@community.nospam>
| > | | Subject: DataItem in DataListItem is null.
| > | | Date: Mon, 21 Nov 2005 10:01:33 +0100
| > | | Lines: 67
| > | | X-Priority: 3
| > | | X-MSMail-Priority: Normal
| > | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| > | | X-RFC2646: Format=Flowed; Original
| > | | Message-ID: <e6**************@TK2MSFTNGP12.phx.gbl>
| > | | Newsgroups:
| > |
| >
microsoft.public.dotnet.framework.aspnet,microsoft .public.dotnet.framework.a
| > | spnet.webcontrols
| > | | NNTP-Posting-Host: gw.coty.cz 195.47.52.129
| > | | Path:
TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFT NGP12.phx.gbl
| > | | Xref: TK2MSFTNGXA02.phx.gbl
| > | microsoft.public.dotnet.framework.aspnet.webcontro ls:31227
| > | microsoft.public.dotnet.framework.aspnet:359739
| > | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > | |
| > | | Hello,
| > | |
| > | | the problem I have now, is:
| > | |
| > | | Im binding generic collection based on List<iDB2SQLTransferItem> //
| > | | iDB2SQLTransferItem is my class // into WebCOntrol DataList. But the
| > | | DataItem of the DataListCommandEventArgs is null. Here is my code:
| > | |
| > | | private MyData.iDB2SQLTransfers transfers = null;
| > | |
| > | | protected void Page_Load(object sender, EventArgs e)
| > | | {
| > | | AppSettingsReader apReader = new AppSettingsReader();
| > | | string dtdPath = (string)apReader.GetValue("DTDPath",
| > typeof(string));
| > | | transfers = iDB2SQLTransfers.Load(dtdPath);
| > | | this.dlDTDefinitions.DataSource = transfers;
| > | | this.dlDTDefinitions.DataBind();
| > | | }
| > | |
| > | | protected void dlDTDefinitions_ItemCommand(object source,
| > | | DataListCommandEventArgs e)
| > | | {
| > | | switch(e.CommandName)
| > | | {
| > | |
| > | | case "Save":
| > | | // Here i suppose, that in the DataItem is edited item
| > typeof
| > | | iDB2SQLTransferItem
| > | | // but it is null. (ListItemType is right - EditItem)
| > | | iDB2SQLTransferItem item =
| > | (iDB2SQLTransferItem)e.Item.DataItem
| > | | dlDTDefinitions.EditItemIndex = -1;
| > | | dlDTDefinitions.SelectedIndex = e.Item.ItemIndex;
| > | | break;
| > | | }
| > | |
| > | | ---------------------------------------------
| > | | Code in aspx page // Only EditItemTemplate //
| > | | ---------------------------------------------
| > | |
| > | | <EditItemTemplate>
| > | | <table>
| > | | <tr>
| > | | <td>ID:</td>
| > | | <td nowrap="nowrap" valign="top"><%#
| > | | DataBinder.Eval(Container.DataItem, "ID")%></td>
| > | | <td>Caption:</td>
| > | | <td>
| > | | <asp:TextBox ID="txtCaption" runat="server"
Text='<%#
| > | | DataBinder.Eval(Container.DataItem, "Caption")
%>'></asp:TextBox></td>
| > | | <td>Description:</td>
| > | | <td>
| > | | <asp:TextBox ID="txtDescription" runat="server"
| > | | Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>'
| > | | ></asp:TextBox></td>
| > | | </tr>
| > | | </table>
| > | |
| > | | ==================================================
| > | |
| > | | All is working well, data are viewed, commands are working well,
but
| > on
| > | Save
| > | | command I need to get edited iDB2SQLTransferItem and save it.
| > | |
| > | | Thanks for ideas.
| > | |
| > | | Mirek
| > | |
| > | |
| > | |
| > |
| > |
| >
|
|
|

Nov 28 '05 #5
Steven Cheng[MSFT] schrieb:
Hi Mirek,

Welcome to ASPNET newsgroup.
Regarding on the DataList databinding with Generic List instance problem, I
think we should use the DataList's "ItemDataBound" event instead of the
"ItemCommand" event. The "Itemcommand" event is used for processing
DataList's Postback events , such as "Edit", "update".... If we need to
programmatically access the current bound datasource's dataitems and do
customization on the DataList's inner Control with the DataItem, we should
use the "ItemDataBound" event , this event will be fired when each DataItem
has been bound to the DataList's certain Row.....

If there're anything else unclear, please feel free to post here.
|
| Hello,
|
| the problem I have now, is:
|
| Im binding generic collection based on List<iDB2SQLTransferItem> //
| iDB2SQLTransferItem is my class // into WebCOntrol DataList. But the
| DataItem of the DataListCommandEventArgs is null. Here is my code:
|


Well, I have a similar but sligthly different problem :) I have a
ButtonColumn in my DataGrid (which is populated by an arraylist of
custom objects). When the users clicks on the button, I would like to
access the custom object that was "selected". So I tried:

private void ResultListGrid_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (((LinkButton)e.CommandSource).CommandName == "Select")
{
WhoIsWhoPerson mySelectedPerson = (WhoIsWhoPerson)e.Item.DataItem;
but "mySelectedPerson" is always "empty" ... any suggestions?
Dec 15 '05 #6
Steven Cheng[MSFT] schrieb:
Hi Mirek,

Welcome to ASPNET newsgroup.
Regarding on the DataList databinding with Generic List instance problem, I
think we should use the DataList's "ItemDataBound" event instead of the
"ItemCommand" event. The "Itemcommand" event is used for processing
DataList's Postback events , such as "Edit", "update".... If we need to
programmatically access the current bound datasource's dataitems and do
customization on the DataList's inner Control with the DataItem, we should
use the "ItemDataBound" event , this event will be fired when each DataItem
has been bound to the DataList's certain Row.....

If there're anything else unclear, please feel free to post here.
|
| Hello,
|
| the problem I have now, is:
|
| Im binding generic collection based on List<iDB2SQLTransferItem> //
| iDB2SQLTransferItem is my class // into WebCOntrol DataList. But the
| DataItem of the DataListCommandEventArgs is null. Here is my code:
|


Well, I have a similar but sligthly different problem :) I have a
ButtonColumn in my DataGrid (which is populated by an arraylist of
custom objects). When the users clicks on the button, I would like to
access the custom object that was "selected". So I tried:

private void ResultListGrid_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (((LinkButton)e.CommandSource).CommandName == "Select")
{
WhoIsWhoPerson mySelectedPerson = (WhoIsWhoPerson)e.Item.DataItem;
but "mySelectedPerson" is always "empty" ... any suggestions?
Dec 15 '05 #7
Steven Cheng[MSFT] schrieb:
Hi Mirek,

Welcome to ASPNET newsgroup.
Regarding on the DataList databinding with Generic List instance problem, I
think we should use the DataList's "ItemDataBound" event instead of the
"ItemCommand" event. The "Itemcommand" event is used for processing
DataList's Postback events , such as "Edit", "update".... If we need to
programmatically access the current bound datasource's dataitems and do
customization on the DataList's inner Control with the DataItem, we should
use the "ItemDataBound" event , this event will be fired when each DataItem
has been bound to the DataList's certain Row.....

If there're anything else unclear, please feel free to post here.
|
| Hello,
|
| the problem I have now, is:
|
| Im binding generic collection based on List<iDB2SQLTransferItem> //
| iDB2SQLTransferItem is my class // into WebCOntrol DataList. But the
| DataItem of the DataListCommandEventArgs is null. Here is my code:
|


Well, I have a similar but sligthly different problem :) I have a
ButtonColumn in my DataGrid (which is populated by an arraylist of
custom objects). When the users clicks on the button, I would like to
access the custom object that was "selected". So I tried:

private void ResultListGrid_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if (((LinkButton)e.CommandSource).CommandName == "Select")
{
WhoIsWhoPerson mySelectedPerson = (WhoIsWhoPerson)e.Item.DataItem;
but "mySelectedPerson" is always "empty" ... any suggestions?
Dec 15 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Phil Corrin | last post: by
2 posts views Thread by Joel Lyons | last post: by
2 posts views Thread by tshad | last post: by
1 post views Thread by Adam Knight | last post: by
3 posts views Thread by J'son | last post: by
15 posts views Thread by Laser Lu | last post: by
1 post views Thread by Jeff | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.