473,394 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 2218
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Phil Corrin | last post by:
.... but I can get the numerical index using the ItemIndex property. Can anyone tell me how to get the text i.e. the data that is listed in the datalist and that is output in the browser? I've...
2
by: Joel Lyons | last post by:
The help pages make it look like the DataGridItem.DataItem property would return a row from the bound table. Like so: //(during setup) myGrid.DataSource = myDataset.MyTable; myGrid.DataBind();...
2
by: tshad | last post by:
How do I tell how many controls there are in a datalistitem? For example I am going through my datalistitems and dealing with the controls: for each oItem as DataListItem in DataList1.Items ...
1
by: Adam Knight | last post by:
Hi all, A quick question on data item availability? See the function below. Upon clicking an button the following function is executed. My problem is, whenever the DataItem property is access...
3
by: J'son | last post by:
Guys, I have created a custom class that derives from DataList so that I can add some custom client side functionality into each new item row (<td>). Heres the class in its simplest form: ...
2
by: ibiza | last post by:
Hi all, I have a simple scenario where I simply bien a repeater to a datasource. Here's my repeater definition : <asp:Repeater id="rTitles" runat="server" EnableViewState="false"...
15
by: Laser Lu | last post by:
Hi, all, I was tangled by the DataGridItem.DataItem property. I tried to invoke that property to get and display the contents that was bound to the currently selected row. However, an exception...
1
by: Jeff | last post by:
hi asp.net 2.0 I have a GridView on a webpage. This GridView has a TemplateField which again contain a LinkButton. When I click on that LinkButton I want some action to take place on that row...
1
by: Bresco | last post by:
I'm using ObjectDatasource in combination with a Formview. The ObjectDatasource is connected to a FormView. I have a business object property which I can't update through the normal binding...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.