Hi Mirek
Thanks for your posting.
Regarding on this issue, I've also found your another duplicated thread in
the microsoft.public.dotnet.framework.aspnet newsgroup, I've posted my
reply there. I'd appreciate if you have a look there. Also, if you feel it
convenient that we continue to discuss in that thread, 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.)
--------------------
| From: "Mirek Endys" <MirekE@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: <e6aCton7FHA.2384@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!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:31227
microsoft.public.dotnet.framework.aspnet:359739
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| 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
|
|
|