Hi Kieren,
As for the ListView EditIndex and EditItem, I think it is the same as
GridView. For such template databound control(support edit/update),
whenever the current edit row(EditIndex) changes, it will need to reperform
the databinding on the control so as to reflect the new editing row status.
Therefore, at the time you change the editIndex, the "EditItem" property is
not populated yet. Though you can access the Item through
ListView.Items[EditIndex], it is still the original populated readonly
version. If you do need to access the EditItem, you can attach the
"ListView.DataBound" event, at that time, the EditItem has been populated.
e.g.
-=-=-=============
protected void ListView1_DataBound(object sender, EventArgs e)
{
Response.Write("<br/>ListView1_DataBound");
Response.Write("<br>ListView+EditIndex: " + ListView1.EditIndex);
Response.Write("<br>ListView+EditItem: " + ListView1.EditItem);
if(ListView1.EditIndex >=0)
Response.Write("<br>ListView+Items[EditIndex]: " +
ListView1.Items[ListView1.EditIndex]);
}
===============
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?S2llcmVuSA==?= <
[email protected]>
Subject: ListView EditItem bug
Date: Thu, 10 Apr 2008 18:44:00 -0700
If you set the EditIndex of a listview to 0, and then try and get the
EditItem, it is null.
EditIndex is documented as being zero-based.
Stepping into the code you can see:
public virtual ListViewItem get_EditItem()
{
if ((this._editIndex > 0) && (this._editIndex < this.Items.Count))
{
return this.Items[this._editIndex];
}
return null;
}
ListView.Items[ 0 ] returns the correct item.
Using NetFX 3.5.