Power Packs 3.0 Data Repeater

C

CypherDrive

I can't add a control on a data repeater included on Visual Basic Power
Packs 3.0...
Will you please help me out. I'm using MS Access 2003 and Visual Basic.NEt
2005 Express. I will be using a weak type. I was just starting to build.
Here are the steps.

1. I created a form
2. I Drag a data repeater from the Toolbox
3. I add a textbox inside the data repeater
4. When I run the Form. The Textbox did not appear.
5. It did not generate any error then..
6. When I click Close or Click a part of the Form:
Object reference not set to an instance of an object.


System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="Microsoft.VisualBasic.PowerPacks"
StackTrace:
at
Microsoft.VisualBasic.PowerPacks.NullDataManager.CancelCurrentEdit()
at Microsoft.VisualBasic.PowerPacks.DataRepeater.CancelEdit()
at Microsoft.VisualBasic.PowerPacks.DataRepeater.EndCurrentItemEdit()
at
Microsoft.VisualBasic.PowerPacks.DataRepeater.OnValidating(CancelEventArgs
e)
at System.Windows.Forms.Control.PerformControlValidation(Boolean
bulkValidation)
at
System.Windows.Forms.ContainerControl.ValidateThroughAncestor(Control
ancestorControl, Boolean preventFocusChangeOnError)
at System.Windows.Forms.ContainerControl.ValidateInternal(Boolean
checkAutoValidate, Boolean& validatedControlAllowsFocusChange)
at System.Windows.Forms.ContainerControl.Validate(Boolean
checkAutoValidate)
at System.Windows.Forms.Form.WmClose(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Form.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmSysCommand(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr
wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Form.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmNcButtonDown(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&
msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationContext context)
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[]
commandLine)
at Purchasing_and_Warehousing_System.My.MyApplication.Main(String[]
Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()


What does this mean?
 
Z

Zhi-xin Ye

Dear CypherDrive,

Base on my understanding, you add a TextBox to the DataRepeater in the
designer without assigning a data source for the DataRepeater control, at
run time, you don't see the TextBox , and you receive the
NullReferenceException error when closing the form.

When you drag a TextBox into the inner section of the DataRepeater in the
designer, the control will be added to the ItemTemplate of the
DataRepeater. At run time, the ItemTemplate is copied to a virtual
DataRepeaterItem object that is used to display the data when each record
is scrolled into view. So if there's no records in the DataRepeater, you
won't see the TextBox at all.

For the exception error you got, let's look into the details,

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of
an object.
at Microsoft.VisualBasic.PowerPacks.NullDataManager.CancelCurrentEdit()
at Microsoft.VisualBasic.PowerPacks.DataRepeater.CancelEdit()
at Microsoft.VisualBasic.PowerPacks.DataRepeater.EndCurrentItemEdit()
at
Microsoft.VisualBasic.PowerPacks.DataRepeater.OnValidating(CancelEventArgs
e)
at System.Windows.Forms.Control.PerformControlValidation(Boolean
bulkValidation)
......

We can see that when the form is closing, the DataRepeater control try to
validate the editing, the calling procedure is as follows:

DataRepeater.OnValidating method
-> DataRepeater.EndCurrentItemEdit()
-> DataRepeater.CancelEdit()
-> NullDataManager.CancelCurrentEdit()

And then the NullDataManager.CancelCurrentEdit() method throws the
exception.

This is because there's an IDataManager object inside the DataRepeater
control for managing data.

The IDataManager is an interface, there are three classess implement this
interface:

* DataManager class
* NullDataManager class
* VirtualDataManager class

By default, if we don't specify a data source for the DataRepeater control,
the underlying logic will instantiate the IDataManager object with
NullDataManager class.

And the CancelCurrentEdit() of the NullDataManager class does nothing but
throws the NullReferenceException error. That's why you receive the
exception.

To avoid this exception, we can either assign a data source for the
DataReapter control or using the VirtualMode in the DataRepeater control.

For more information about how to do this, you can read these documents:

How to: Display Bound Data in a DataRepeater Control
http://msdn.microsoft.com/en-us/library/cc425004(VS.80).aspx

Virtual Mode in the DataRepeater Control
http://msdn.microsoft.com/en-us/library/cc424994(VS.80).aspx

How to: Display Unbound Data in a DataRepeater Control
http://msdn.microsoft.com/en-us/library/cc425005(VS.80).aspx

For more information about the DataRepeater control, you can read this
document:

Introduction to the DataRepeater Control
http://msdn.microsoft.com/en-us/library/cc425024(VS.80).aspx

If you need further help on this, please don't hesitate to let me know.
Thanks.

Sincerely,
Zhi-Xin Ye
Microsoft Newsgroup Support Team

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.
 
Z

Zhi-xin Ye

Dear CypherDrive,

I haven't heard back from you so I would like to follow up to find out
whether the information I supplied makes any sense to you or not. If there
is anything more I can help with, please don't hesitate to let me know.
Thanks.

Sincerely,
Zhi-Xin Ye
Microsoft Online Community Support
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top