Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why this code returns null?
Message
From
15/09/2008 12:50:45
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01347651
Message ID:
01347690
Views:
13
>>Hi,
>>
>>>I use similar code in other places and it works fine, but for some reason in RowDeleted event this code
>>>
>>> DataRowView view = ProfilesGrid.Rows[e.RowIndex].DataItem as DataRowView;
>>>
>>>returns null. The DataItem is null, but the type is DataRow
>>
>>Don't really see how view could be other than null if the Datatem is null...
>>>
>>>Is my only option to try to get names through columns (cells)?
>>
>>Not sure that I understand what you intended to do with the DataRowView if it was available?
>>Regards,
>>Viv
>
>Viv,
>
>I changed this code to this and it works, but why DataItem is null?

Because the Row isn't bound ?
>
>
>DataRowView view = ProfilesGrid.Rows[e.RowIndex].DataItem as DataRowView;
>            if (view != null)
>                PersonName = view["FirstName"].ToString() +
>                            " " + view["LastName"].ToString();
>            else
>                PersonName = ProfilesGrid.Rows[e.RowIndex].Cells[6].Text + " " + ProfilesGrid.Rows[e.RowIndex].Cells[5].Text;
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform