470,849 Members | 1,211 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Need Help.

I have a DataTable with a integer field called SortOrder.

This table is loaded with and XML file.

I have this table in a DataView and I set the RowFilter to filter some row,
then I change the SortOrder, set the Sort property to "SortOrder".

This works fine the first 20 to 50 times. Then I get this error.

This error does not occur if I do not set the Sort property to SortOrder.
If I set the Sort property to another column or blank the error never

================================================== =======================
Additional information: Object reference not set to an instance of an
Unhandled Exception: System.NullReferenceException: Object reference not set
to an instance of an object.
System.Data.DataRowView.System.ComponentModel.IDat aErrorInfo.get_Error()
at System.Windows.Forms.DataGridRow.PaintHeader(Graph ics g, Rectangle
visualBounds, Boolean alignToRight, Boolean rowIsDirty)
System.Windows.Forms.DataGridRelationshipRow.Paint HeaderInside(Graphics g,
Rectangle bounds, Brush backBr, Boolean alignToRight, Boolean isDirty)
at System.Windows.Forms.DataGridRelationshipRow.Paint Header(Graphics g,
Rectangle bounds, Boolean alignToRight, Boolean isDirty)
at System.Windows.Forms.DataGrid.PaintRows(Graphics g, Rectangle&
at System.Windows.Forms.DataGrid.PaintGrid(Graphics g, Rectangle
at System.Windows.Forms.DataGrid.OnPaint(PaintEventAr gs pe)
at System.Windows.Forms.Control.PaintWithErrorHandlin g(PaintEventArgs e,
Int16 layer, Boolean disposeEventArgs)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
System.Windows.Forms.ComponentManager.System.Windo ws.Forms.UnsafeNativeMetho
ds+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason,
Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopI nner(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop( Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Maxine.frmMain.Main() in c:\ab-visual studio
projects\maxinexml-2\formmain.cs:line 851
The program '[1052] Maxine.exe' has exited with code 0 (0x0).

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

Here is a code snippett.
//================================================== ========================
// update the DataView from the songs that are in the list;
// the dataview will show them in the correct order
public void UpdateView()
if (dview == null)
{ return; } // no view so exit

int sort = 1;
if (al.Count == 0) // no songs in play list
dview.RowFilter = "theIndex = -1"; // no
songs will pass this filter
String filter = "";
foreach (String s in al)
Debug.WriteLine("Sort Number " + s);
filter = filter + "theIndex = '" + s + "' OR
DataRow dr =
//DataRow dr = dview.Table.;
if (dr != null)
dr["SortOrder"] = sort; //
sort order field on songs is the order
// that they will be displayed (and played)
if (dr.HasErrors)
Debug.WriteLine("Got and error in edit"); }
catch(Exception e1)
trying to write a sort order" + e1.Message);
Debug.WriteLine("Got a null pointer
for: " + s);
filter = filter.Remove(filter.Length-4,4); //
remove the last "OR"
Debug.WriteLine("Filter: " + filter);
dview.RowFilter = filter;
dview.Sort = "SortOrder";
catch(Exception e)
Debug.WriteLine("Got an error doing a sort:
" + e.Message);

Nov 12 '05 #1
0 1300

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by mike | last post: by
5 posts views Thread by John Flynn | last post: by
reply views Thread by xunling | last post: by
7 posts views Thread by Timothy Shih | last post: by
8 posts views Thread by skumar434 | last post: by
reply views Thread by U S Contractors Offering Service A Non-profit | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.